diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj index 8e26d98..d6228a2 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs index 28d0aee..8809e87 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs @@ -1,27 +1,21 @@ -using EasyMicroservices.ContentsMicroservice.Database; -using EasyMicroservices.Cores.Relational.EntityFrameworkCore.Intrerfaces; +using EasyMicroservices.Cores.Relational.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EasyMicroservices.ContentsMicroservice { - public class DatabaseBuilder : IEntityFrameworkCoreDatabaseBuilder + public class DatabaseBuilder : EntityFrameworkCoreDatabaseBuilder { - IConfiguration _configuration; - public DatabaseBuilder(IConfiguration configuration) + public DatabaseBuilder(IConfiguration configuration) : base(configuration) { - _configuration = configuration; } - public void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + public override void OnConfiguring(DbContextOptionsBuilder optionsBuilder, string name) { - optionsBuilder.UseInMemoryDatabase("ContentDatabase"); - //optionsBuilder.UseSqlServer(_configuration.GetConnectionString("local")); + if (name == "SqlServer") + optionsBuilder.UseSqlServer(Configuration.GetConnectionString("local")); + else + optionsBuilder.UseInMemoryDatabase("Contents"); } } } diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj index 52d2312..eadaff3 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj @@ -8,7 +8,6 @@ - diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj index e7251b6..fce63d4 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Controllers/ContentController.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Controllers/ContentController.cs index c6cb91c..f7e0a5d 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Controllers/ContentController.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Controllers/ContentController.cs @@ -22,8 +22,8 @@ public override async Task> Add(CreateContentRequestContra { using var categorylogic = unitOfWork.GetLongContractLogic(); using var languageLogic = unitOfWork.GetLongContractLogic(); - var checkLanguageId = await languageLogic.GetById(new GetIdRequestContract() { Id = request.LanguageId }); - var checkCategoryId = await categorylogic.GetById(new GetIdRequestContract() { Id = request.CategoryId }); + var checkLanguageId = await languageLogic.GetById(new GetByIdRequestContract() { Id = request.LanguageId }); + var checkCategoryId = await categorylogic.GetById(new GetByIdRequestContract() { Id = request.CategoryId }); if (checkLanguageId.IsSuccess && checkCategoryId.IsSuccess) return await base.Add(request, cancellationToken); return (FailedReasonType.Incorrect, "Language or Categoryid is incorrect"); @@ -33,8 +33,8 @@ public override async Task> Update(UpdateConten { using var categorylogic = unitOfWork.GetLongContractLogic(); using var languageLogic = unitOfWork.GetLongContractLogic(); - var checkLanguageId = await languageLogic.GetById(new GetIdRequestContract() { Id = request.LanguageId }); - var checkCategoryId = await categorylogic.GetById(new GetIdRequestContract() { Id = request.CategoryId }); + var checkLanguageId = await languageLogic.GetById(new GetByIdRequestContract() { Id = request.LanguageId }); + var checkCategoryId = await categorylogic.GetById(new GetByIdRequestContract() { Id = request.CategoryId }); if (checkLanguageId.IsSuccess && checkCategoryId.IsSuccess) return await base.Update(request, cancellationToken); return (FailedReasonType.Incorrect, "Language or Categoryid is incorrect"); @@ -122,7 +122,7 @@ public async Task> AddContentWithKey(AddConten }); } - var addedCategoryResult = await categorylogic.GetById(new GetIdRequestContract + var addedCategoryResult = await categorylogic.GetById(new GetByIdRequestContract { Id = addCategoryResult.Result }); diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json index 65d0fc6..b5586bb 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json @@ -7,10 +7,24 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "local": "Server=.;Database=Contents;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" + "local": "Server=.;Database=Contents;User ID=TrustServerCertificate=True;" + }, + "Database": { + "ProviderName": "InMemory" + }, + "Authorization": { + "Use": false, + "JWT": { + "Key": "VGhpc0lzGHGHGHlY3JldEtleUZvckp3dEF1dGhlbnRpY2F0aW9u=", + "Issuer": "https://github.com/easymicroservices", + "Audience": "easymicroservices", + + "TokenExpireTimeInSeconds": 86400 + } }, "RootAddresses": { - "WhiteLabel": "http://localhost:1041" + "WhiteLabel": "http://localhost:1041", + "Authentication": "http://localhost:1044" }, "Urls": "http://*:2003" } \ No newline at end of file