Skip to content

Commit

Permalink
Merge pull request #39 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
simple refactor
  • Loading branch information
Ali-YousefiTelori authored Dec 24, 2023
2 parents fca6ea1 + 88da397 commit 79f4eaa
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EasyMicroservices.Cores.AspEntityFrameworkCoreApi" Version="*" />
<PackageReference Include="EasyMicroservices.Cores.AspEntityFrameworkCoreApi" Version="0.0.0.70" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<ItemGroup>
<PackageReference Include="EasyMicroservices.WhiteLabelsMicroservice.Clients" Version="*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.14" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EasyMicroservices.ContentsMicroservice.Clients" Version="*" />
<PackageReference Include="EasyMicroservices.ContentsMicroservice.Clients" Version="0.0.0.20" />
<PackageReference Include="EasyMicroservices.Tests" Version="*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public override async Task<MessageContract<long>> Add(CreateContentRequestContra
{
using var categorylogic = unitOfWork.GetLongContractLogic<CategoryEntity, CreateCategoryRequestContract, UpdateCategoryRequestContract, CategoryContract>();
using var languageLogic = unitOfWork.GetLongContractLogic<LanguageEntity, LanguageContract>();
var checkLanguageId = await languageLogic.GetById(new GetIdRequestContract<long>() { Id = request.LanguageId });
var checkCategoryId = await categorylogic.GetById(new GetIdRequestContract<long>() { Id = request.CategoryId });
var checkLanguageId = await languageLogic.GetById(new GetByIdRequestContract<long>() { Id = request.LanguageId });
var checkCategoryId = await categorylogic.GetById(new GetByIdRequestContract<long>() { Id = request.CategoryId });
if (checkLanguageId.IsSuccess && checkCategoryId.IsSuccess)
return await base.Add(request, cancellationToken);
return (FailedReasonType.Incorrect, "Language or Categoryid is incorrect");
Expand All @@ -33,8 +33,8 @@ public override async Task<MessageContract<ContentContract>> Update(UpdateConten
{
using var categorylogic = unitOfWork.GetLongContractLogic<CategoryEntity, CreateCategoryRequestContract, UpdateCategoryRequestContract, CategoryContract>();
using var languageLogic = unitOfWork.GetLongContractLogic<LanguageEntity, LanguageContract>();
var checkLanguageId = await languageLogic.GetById(new GetIdRequestContract<long>() { Id = request.LanguageId });
var checkCategoryId = await categorylogic.GetById(new GetIdRequestContract<long>() { Id = request.CategoryId });
var checkLanguageId = await languageLogic.GetById(new GetByIdRequestContract<long>() { Id = request.LanguageId });
var checkCategoryId = await categorylogic.GetById(new GetByIdRequestContract<long>() { Id = request.CategoryId });
if (checkLanguageId.IsSuccess && checkCategoryId.IsSuccess)
return await base.Update(request, cancellationToken);
return (FailedReasonType.Incorrect, "Language or Categoryid is incorrect");
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task<MessageContract<CategoryContract>> AddContentWithKey(AddConten
});
}

var addedCategoryResult = await categorylogic.GetById(new GetIdRequestContract<long>
var addedCategoryResult = await categorylogic.GetById(new GetByIdRequestContract<long>
{
Id = addCategoryResult.Result
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 79f4eaa

Please sign in to comment.