Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
guru
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
guru
Commits
00d842fe
Commit
00d842fe
authored
Dec 23, 2018
by
Clint.Network
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to Dependency Injection
parent
8d1f3047
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
117 additions
and
10 deletions
+117
-10
DatabaseContext.cs
Stratis.Guru/DatabaseContext.cs
+27
-0
IMongoContext.cs
Stratis.Guru/DependencyInjection/IMongoContext.cs
+0
-7
Draw.cs
Stratis.Guru/Models/Draw.cs
+1
-1
Draws.cs
Stratis.Guru/Models/Draws.cs
+32
-0
IDraws.cs
Stratis.Guru/Models/IDraws.cs
+11
-0
ISettings.cs
Stratis.Guru/Models/ISettings.cs
+12
-0
Setting.cs
Stratis.Guru/Models/Setting.cs
+2
-2
Settings.cs
Stratis.Guru/Models/Settings.cs
+29
-0
Startup.cs
Stratis.Guru/Startup.cs
+3
-0
No files found.
Stratis.Guru/DatabaseContext.cs
0 → 100644
View file @
00d842fe
using
System
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.Options
;
using
MongoDB.Driver
;
using
Stratis.Guru.Models
;
using
Stratis.Guru.Services
;
using
Stratis.Guru.Settings
;
namespace
Stratis.Guru
{
public
class
DatabaseContext
{
private
readonly
IMongoDatabase
_database
;
public
DatabaseContext
(
IConfiguration
configuration
)
{
var
client
=
new
MongoClient
(
configuration
.
GetConnectionString
(
"DefaultConnection"
));
if
(
client
!=
null
)
{
_database
=
client
.
GetDatabase
(
"stratis-guru"
);
}
}
public
IMongoCollection
<
Draw
>
Draws
=>
_database
.
GetCollection
<
Draw
>(
"draws"
);
public
IMongoCollection
<
Setting
>
Settings
=>
_database
.
GetCollection
<
Setting
>(
"lottery"
);
}
}
\ No newline at end of file
Stratis.Guru/DependencyInjection/IMongoContext.cs
deleted
100644 → 0
View file @
8d1f3047
namespace
Stratis.Guru.DependencyInjection
{
public
interface
IMongoContext
{
}
}
\ No newline at end of file
Stratis.Guru/Models/
Lottery
Draw.cs
→
Stratis.Guru/Models/Draw.cs
View file @
00d842fe
...
@@ -3,7 +3,7 @@ using MongoDB.Bson.Serialization.Attributes;
...
@@ -3,7 +3,7 @@ using MongoDB.Bson.Serialization.Attributes;
namespace
Stratis.Guru.Models
namespace
Stratis.Guru.Models
{
{
public
class
Lottery
Draw
public
class
Draw
{
{
[
BsonId
]
[
BsonId
]
public
ObjectId
Id
{
get
;
set
;
}
public
ObjectId
Id
{
get
;
set
;
}
...
...
Stratis.Guru/Models/Draws.cs
0 → 100644
View file @
00d842fe
using
System
;
using
System.Collections.ObjectModel
;
using
System.Threading.Tasks
;
using
MongoDB.Bson
;
using
MongoDB.Driver
;
using
Stratis.Guru
;
using
Stratis.Guru.Services
;
namespace
Stratis.Guru.Models
{
public
class
Draws
:
IDraws
{
private
DatabaseContext
_databaseContext
;
public
Draws
(
DatabaseContext
databaseContext
)
{
_databaseContext
=
databaseContext
;
}
public
async
Task
InitDrawAsync
(
long
nextDrawTimestamp
)
{
if
(!
_databaseContext
.
Draws
.
Find
(
x
=>
x
.
DrawDate
.
Equals
(
nextDrawTimestamp
)).
Any
())
{
await
_databaseContext
.
Draws
.
InsertOneAsync
(
new
Draw
()
{
DrawDate
=
nextDrawTimestamp
,
Passed
=
false
});
}
}
}
}
\ No newline at end of file
Stratis.Guru/Models/IDraws.cs
0 → 100644
View file @
00d842fe
using
System.Threading.Tasks
;
namespace
Stratis.Guru.Models
{
public
interface
IDraws
{
Task
InitDrawAsync
(
long
nextDrawTimestamp
);
}
}
\ No newline at end of file
Stratis.Guru/Models/ISettings.cs
0 → 100644
View file @
00d842fe
using
System.Threading.Tasks
;
namespace
Stratis.Guru.Models
{
public
interface
ISettings
{
Task
InitAsync
();
int
GetIterator
();
}
}
\ No newline at end of file
Stratis.Guru/Models/
Lottery
Setting.cs
→
Stratis.Guru/Models/Setting.cs
View file @
00d842fe
using
MongoDB.Bson
;
using
MongoDB.Bson
;
using
MongoDB.Bson.Serialization.Attributes
;
using
MongoDB.Bson.Serialization.Attributes
;
namespace
Stratis.Guru.
Service
s
namespace
Stratis.Guru.
Model
s
{
{
public
class
Lottery
Setting
public
class
Setting
{
{
[
BsonId
]
[
BsonId
]
public
ObjectId
Id
{
get
;
set
;
}
public
ObjectId
Id
{
get
;
set
;
}
...
...
Stratis.Guru/Models/Settings.cs
0 → 100644
View file @
00d842fe
using
System.Threading.Tasks
;
using
MongoDB.Driver
;
namespace
Stratis.Guru.Models
{
public
class
Settings
:
ISettings
{
private
DatabaseContext
_databaseContext
;
public
Settings
(
DatabaseContext
databaseContext
)
{
_databaseContext
=
databaseContext
;
}
public
int
GetIterator
()
=>
_databaseContext
.
Settings
.
Find
(
x
=>
true
).
FirstOrDefault
().
PublicKeyIterator
;
public
async
Task
InitAsync
()
{
if
(!
_databaseContext
.
Settings
.
Find
(
x
=>
true
).
Any
())
{
await
_databaseContext
.
Settings
.
InsertOneAsync
(
new
Setting
{
PublicKeyIterator
=
0
});
}
}
}
}
\ No newline at end of file
Stratis.Guru/Startup.cs
View file @
00d842fe
...
@@ -56,6 +56,9 @@ namespace Stratis.Guru
...
@@ -56,6 +56,9 @@ namespace Stratis.Guru
services
.
AddTransient
<
UpdateHub
>();
services
.
AddTransient
<
UpdateHub
>();
services
.
AddSingleton
<
IAsk
,
Ask
>();
services
.
AddSingleton
<
IAsk
,
Ask
>();
services
.
AddTransient
<
DatabaseContext
>();
services
.
AddSingleton
<
ISettings
,
Models
.
Settings
>();
services
.
AddSingleton
<
IDraws
,
Draws
>();
services
.
AddHostedService
<
UpdateInfosService
>();
services
.
AddHostedService
<
UpdateInfosService
>();
services
.
AddHostedService
<
FixerService
>();
services
.
AddHostedService
<
FixerService
>();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment