Skip to content

Commit d73a9a1

Browse files
committed
mongodb provider (cont.) #22
1 parent 8e6b438 commit d73a9a1

File tree

19 files changed

+781
-210
lines changed

19 files changed

+781
-210
lines changed

netcorekit.sln

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "protos", "protos", "{B955EE
6868
samples\protos\project.proto = samples\protos\project.proto
6969
EndProjectSection
7070
EndProject
71-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCoreKit.Infrastructure.Mongo", "src\NetCoreKit.Infrastructure.Mongo\NetCoreKit.Infrastructure.Mongo.csproj", "{BAAB999F-EF03-4575-8FD4-9989A544319E}"
71+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Infrastructure.Mongo", "src\NetCoreKit.Infrastructure.Mongo\NetCoreKit.Infrastructure.Mongo.csproj", "{BAAB999F-EF03-4575-8FD4-9989A544319E}"
72+
EndProject
73+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCoreKit.Samples.BiMonetaryApi", "samples\NetCoreKit.Samples.BiMonetaryApi\NetCoreKit.Samples.BiMonetaryApi.csproj", "{315187EE-4BA7-4B16-A653-A88B62757776}"
7274
EndProject
7375
Global
7476
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -230,6 +232,14 @@ Global
230232
{BAAB999F-EF03-4575-8FD4-9989A544319E}.Release|Any CPU.Build.0 = Release|Any CPU
231233
{BAAB999F-EF03-4575-8FD4-9989A544319E}.Release|x86.ActiveCfg = Release|Any CPU
232234
{BAAB999F-EF03-4575-8FD4-9989A544319E}.Release|x86.Build.0 = Release|Any CPU
235+
{315187EE-4BA7-4B16-A653-A88B62757776}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
236+
{315187EE-4BA7-4B16-A653-A88B62757776}.Debug|Any CPU.Build.0 = Debug|Any CPU
237+
{315187EE-4BA7-4B16-A653-A88B62757776}.Debug|x86.ActiveCfg = Debug|Any CPU
238+
{315187EE-4BA7-4B16-A653-A88B62757776}.Debug|x86.Build.0 = Debug|Any CPU
239+
{315187EE-4BA7-4B16-A653-A88B62757776}.Release|Any CPU.ActiveCfg = Release|Any CPU
240+
{315187EE-4BA7-4B16-A653-A88B62757776}.Release|Any CPU.Build.0 = Release|Any CPU
241+
{315187EE-4BA7-4B16-A653-A88B62757776}.Release|x86.ActiveCfg = Release|Any CPU
242+
{315187EE-4BA7-4B16-A653-A88B62757776}.Release|x86.Build.0 = Release|Any CPU
233243
EndGlobalSection
234244
GlobalSection(SolutionProperties) = preSolution
235245
HideSolutionNode = FALSE
@@ -256,6 +266,7 @@ Global
256266
{94E34AF7-42CA-4BBC-B444-FC17915B4D55} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
257267
{B955EE6A-DBD9-474A-AE34-E1960E887F0F} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
258268
{BAAB999F-EF03-4575-8FD4-9989A544319E} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
269+
{315187EE-4BA7-4B16-A653-A88B62757776} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
259270
EndGlobalSection
260271
GlobalSection(ExtensibilityGlobals) = postSolution
261272
SolutionGuid = {B9325AE8-21A8-4D46-9B04-38BD2BC35C0F}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Microsoft.AspNetCore.Mvc;
5+
using NetCoreKit.Domain;
6+
7+
namespace NetCoreKit.Samples.BiMonetaryApi.Controllers
8+
{
9+
public class Ticker : AggregateRootBase
10+
{
11+
public string Name { get; set; }
12+
public string Symbol { get; set; }
13+
public int Rank { get; set; }
14+
public double PriceUsd { get; private set; }
15+
public double PriceBtc { get; private set; }
16+
public double Volumn24hUsd { get; private set; }
17+
public double MarketCapUsd { get; private set; }
18+
public double AvailableSupply { get; private set; }
19+
public double TotalSupply { get; private set; }
20+
public string PercentChange1h { get; private set; }
21+
public string PercentChange24h { get; private set; }
22+
public string PercentChange7d { get; private set; }
23+
public DateTime LastSyncWithService { get; private set; }
24+
public string Link { get; private set; }
25+
}
26+
27+
[Route("api/tickers")]
28+
[ApiController]
29+
public class TickerController : ControllerBase
30+
{
31+
private readonly IQueryRepositoryFactory _repositoryFactory;
32+
private readonly IUnitOfWorkAsync _uow;
33+
34+
public TickerController(IQueryRepositoryFactory repositoryFactory, IUnitOfWorkAsync uow)
35+
{
36+
_repositoryFactory = repositoryFactory;
37+
_uow = uow;
38+
}
39+
40+
// GET api/tickers
41+
[HttpGet]
42+
public ActionResult<IEnumerable<Ticker>> Get()
43+
{
44+
var repo = _repositoryFactory.QueryRepository<Ticker>();
45+
var tickers = repo.Queryable().ToList();
46+
return tickers;
47+
}
48+
49+
// GET api/tickers/{C35A5A15-0913-43A0-BAD5-00FE9749C320}
50+
[HttpGet("{id:guid}")]
51+
public ActionResult<Ticker> Get(Guid id)
52+
{
53+
var repo = _repositoryFactory.QueryRepository<Ticker>();
54+
var ticker = repo.Queryable().FirstOrDefault(x => x.Id == id);
55+
return ticker;
56+
}
57+
58+
// POST api/tickers
59+
[HttpPost]
60+
public void Post([FromBody] Ticker ticker)
61+
{
62+
var repo = _uow.RepositoryAsync<Ticker>();
63+
repo.AddAsync(ticker);
64+
}
65+
}
66+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<AspNetCoreHostingModel>inprocess</AspNetCoreHostingModel>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.AspNetCore.App" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\src\NetCoreKit.Domain\NetCoreKit.Domain.csproj" />
14+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.CleanArch\NetCoreKit.Infrastructure.AspNetCore.CleanArch.csproj" />
15+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.Miniservice\NetCoreKit.Infrastructure.AspNetCore.Miniservice.csproj" />
16+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.OpenApi\NetCoreKit.Infrastructure.AspNetCore.OpenApi.csproj" />
17+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore\NetCoreKit.Infrastructure.AspNetCore.csproj" />
18+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.Mongo\NetCoreKit.Infrastructure.Mongo.csproj" />
19+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure\NetCoreKit.Infrastructure.csproj" />
20+
<ProjectReference Include="..\..\src\NetCoreKit.Utils\NetCoreKit.Utils.csproj" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace NetCoreKit.Samples.BiMonetaryApi
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
CreateWebHostBuilder(args).Build().Run();
18+
}
19+
20+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21+
WebHost.CreateDefaultBuilder(args)
22+
.UseStartup<Startup>();
23+
}
24+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:54408",
8+
"sslPort": 0
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"launchUrl": "",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"NetCoreKit.Samples.BiMonetaryApi": {
21+
"commandName": "Project",
22+
"launchBrowser": true,
23+
"launchUrl": "api/values",
24+
"applicationUrl": "http://localhost:5000",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
}
29+
}
30+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.DependencyInjection;
3+
using NetCoreKit.Infrastructure.AspNetCore.Miniservice;
4+
5+
namespace NetCoreKit.Samples.BiMonetaryApi
6+
{
7+
public class Startup
8+
{
9+
public void ConfigureServices(IServiceCollection services)
10+
{
11+
services.AddMongoMiniService();
12+
}
13+
14+
public void Configure(IApplicationBuilder app)
15+
{
16+
app.UseMiniService();
17+
}
18+
}
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Debug",
5+
"System": "Information",
6+
"Microsoft": "Information"
7+
}
8+
}
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"API_VERSION": "1.0",
3+
"SERVICE_VERSION": "0.0.1",
4+
"QualifiedAssemblyPattern": "NetCoreKit.Samples.*",
5+
"Hosts": {
6+
"BasePath": "/",
7+
"Externals": {
8+
"CurrentUri": "http://localhost:54408"
9+
}
10+
},
11+
"Mongo": {
12+
"Enabled": true,
13+
"ConnectionString": "mongodb://127.0.0.1:27017",
14+
"Database": "BiMonetaryApi"
15+
},
16+
"ApiVersion": {
17+
"Enabled": true
18+
},
19+
"OpenApi": {
20+
"Enabled": true,
21+
"UI": {
22+
"Enabled": true
23+
}
24+
},
25+
"Logging": {
26+
"LogLevel": {
27+
"Default": "Warning"
28+
}
29+
},
30+
"AllowedHosts": "*"
31+
}

samples/TodoApi/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"EfCore": {
1212
"Enabled": true
1313
},
14-
"FaultTolerance": {
14+
"RestClient": {
1515
"Enabled": true
1616
},
1717
"CleanArchitecture": {

src/NetCoreKit.Domain/IUnitOfWorkAsync.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public interface IUnitOfWorkAsync : IRepositoryAsyncFactory, IDisposable
88
{
99
int SaveChanges();
1010
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
11-
int ExecuteSqlCommand(string sql, params object[] parameters);
12-
Task<int> ExecuteSqlCommandAsync(string sql, params object[] parameters);
13-
Task<int> ExecuteSqlCommandAsync(string sql, CancellationToken cancellationToken, params object[] parameters);
14-
int? CommandTimeout { get; set; }
11+
// int ExecuteSqlCommand(string sql, params object[] parameters);
12+
// Task<int> ExecuteSqlCommandAsync(string sql, params object[] parameters);
13+
// Task<int> ExecuteSqlCommandAsync(string sql, CancellationToken cancellationToken, params object[] parameters);
14+
// int? CommandTimeout { get; set; }
1515
}
1616
}

0 commit comments

Comments
 (0)