Generator Changes at 9/27/2025 8:46:36 AM

This commit is contained in:
generator
2025-09-27 08:46:36 +03:30
parent fd82e3edcf
commit fd8614f72e
261 changed files with 6333 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.AspNetCore" Version="2.54.0" />
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.54.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.54.0" />
<PackageReference Include="Mapster.DependencyInjection" Version="1.0.0" />
<PackageReference Include="MediatR" Version="11.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Microsoft.AspNetCore.Grpc.Swagger" Version="0.3.8" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.3.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CMSMicroservice.Application\CMSMicroservice.Application.csproj" />
<ProjectReference Include="..\CMSMicroservice.Infrastructure\CMSMicroservice.Infrastructure.csproj" />
<ProjectReference Include="..\CMSMicroservice.Protobuf\CMSMicroservice.Protobuf.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,38 @@
using Grpc.Core.Interceptors;
using Microsoft.Extensions.Logging;
using CMSMicroservice.Application.Common.Interfaces;
namespace CMSMicroservice.WebApi.Common.Behaviours;
public class LoggingBehaviour : Interceptor
{
private readonly ILogger _logger;
private readonly ICurrentUserService _currentUserService;
public LoggingBehaviour(ILogger<LoggingBehaviour> logger, ICurrentUserService currentUserService)
{
_logger = logger;
_currentUserService = currentUserService;
}
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
TRequest request,
ServerCallContext context,
UnaryServerMethod<TRequest, TResponse> continuation)
{
var requestName = typeof(TRequest).Name;
var userId = _currentUserService.UserId ?? string.Empty;
_logger.LogInformation("gRPC Starting receiving call. Type/Method: {Type} / {Method} Request: {Name} {@UserId} {@Request}",
MethodType.Unary, context.Method , requestName, userId, request);
try
{
return await continuation(request, context);
}
catch (Exception ex)
{
_logger.LogError(ex, "gRPC Request: Unhandled Exception for Request {Name} {@Request}", requestName, request);
throw;
}
}
}

View File

@@ -0,0 +1,44 @@
using Grpc.Core.Interceptors;
using Microsoft.Extensions.Logging;
using System.Diagnostics;
using CMSMicroservice.Application.Common.Interfaces;
namespace CMSMicroservice.WebApi.Common.Behaviours;
public class PerformanceBehaviour : Interceptor
{
private readonly Stopwatch _timer;
private readonly ILogger _logger;
private readonly ICurrentUserService _currentUserService;
public PerformanceBehaviour(ILogger<PerformanceBehaviour> logger, ICurrentUserService currentUserService)
{
_timer = new Stopwatch();
_logger = logger;
_currentUserService = currentUserService;
}
public override async Task<TResponse> UnaryServerHandler<TRequest, TResponse>(
TRequest request,
ServerCallContext context,
UnaryServerMethod<TRequest, TResponse> continuation)
{
_timer.Start();
var response = await continuation(request, context);
_timer.Stop();
var elapsedMilliseconds = _timer.ElapsedMilliseconds;
if (elapsedMilliseconds > 500)
{
var requestName = typeof(TRequest).Name;
var userId = _currentUserService.UserId ?? string.Empty;
_logger.LogWarning("gRPC Long Running Request: {Name} ({ElapsedMilliseconds} milliseconds) {@UserId} {@Request}",
requestName, elapsedMilliseconds, userId, request);
}
return response;
}
}

View File

@@ -0,0 +1,64 @@
using System.Globalization;
namespace CMSMicroservice.WebApi.Common.Mappings;
public class GeneralMapping : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
config.NewConfig<string, decimal>()
.MapWith(src => decimal.Parse(src));
config.NewConfig<decimal, string>()
.MapWith(src => src.ToString("R", new CultureInfo("en-us")));
config.NewConfig<decimal?, string>()
.MapWith(src => src == null ? string.Empty : src.Value.ToString("R", new CultureInfo("en-us")));
config.NewConfig<string, decimal?>()
.MapWith(src => string.IsNullOrEmpty(src) ? null : decimal.Parse(src));
config.NewConfig<Guid, string>()
.MapWith(src => src == Guid.Empty ? string.Empty : src.ToString());
config.NewConfig<string, Guid>()
.MapWith(src => string.IsNullOrEmpty(src) ? Guid.Empty : Guid.Parse(src));
config.NewConfig<string, Guid?>()
.MapWith(src => string.IsNullOrEmpty(src) ? null : Guid.Parse(src));
config.NewConfig<Timestamp, DateTime>()
.MapWith(src => src.ToDateTime());
config.NewConfig<Timestamp, DateTime?>()
.MapWith(src => src == null ? null : src.ToDateTime());
config.NewConfig<DateTime, Timestamp>()
.MapWith(src => Timestamp.FromDateTime(DateTime.SpecifyKind(src, DateTimeKind.Utc)));
config.NewConfig<DateTime?, Timestamp>()
.MapWith(src => src.HasValue ? Timestamp.FromDateTime(DateTime.SpecifyKind(src.Value, DateTimeKind.Utc)) : null);
config.NewConfig<Duration, TimeSpan>()
.MapWith(src => src.ToTimeSpan());
config.NewConfig<Duration, TimeSpan?>()
.MapWith(src => src == null ? null : src.ToTimeSpan());
config.NewConfig<TimeSpan, Duration>()
.MapWith(src => Duration.FromTimeSpan(src));
config.NewConfig<TimeSpan?, Duration>()
.MapWith(src => src.HasValue ? Duration.FromTimeSpan(src.Value) : null);
config.Default
.UseDestinationValue(member => member.SetterModifier == AccessModifier.None &&
member.Type.IsGenericType &&
member.Type.GetGenericTypeDefinition() == typeof(Google.Protobuf.Collections.RepeatedField<>));
config.NewConfig<Google.Protobuf.ByteString, byte[]>()
.MapWith(src => src.ToByteArray());
config.NewConfig<byte[], Google.Protobuf.ByteString>()
.MapWith(src => Google.Protobuf.ByteString.CopyFrom(src));
}
}

View File

@@ -0,0 +1,10 @@
namespace CMSMicroservice.WebApi.Common.Mappings;
public class PackageProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace CMSMicroservice.WebApi.Common.Mappings;
public class RoleProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace CMSMicroservice.WebApi.Common.Mappings;
public class UserAddressProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace CMSMicroservice.WebApi.Common.Mappings;
public class UserOrderProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace CMSMicroservice.WebApi.Common.Mappings;
public class UserProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,10 @@
namespace CMSMicroservice.WebApi.Common.Mappings;
public class UserRoleProfile : IRegister
{
void IRegister.Register(TypeAdapterConfig config)
{
//config.NewConfig<Source,Destination>()
// .Map(dest => dest.FullName, src => $"{src.Firstname} {src.Lastname}");
}
}

View File

@@ -0,0 +1,17 @@
using System.Security.Claims;
using CMSMicroservice.Application.Common.Interfaces;
using Microsoft.AspNetCore.Http;
namespace CMSMicroservice.WebApi.Common.Services;
public class CurrentUserService : ICurrentUserService
{
private readonly IHttpContextAccessor _httpContextAccessor;
public CurrentUserService(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string? UserId => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier);
}

View File

@@ -0,0 +1,87 @@
namespace CMSMicroservice.WebApi.Common.Services;
public interface IDispatchRequestToCQRS
{
Task<TResponse> Handle<TRequest, TCommand, TResponse>(TRequest request,
ServerCallContext context);
Task<Empty> Handle<TRequest, TCommand>(TRequest request,
ServerCallContext context);
Task<TResponse> Handle<TCommand, TResponse>(ServerCallContext context);
}
public class DispatchRequestToCQRS : IDispatchRequestToCQRS
{
private readonly ISender _sender;
public DispatchRequestToCQRS(ISender sender)
{
_sender = sender;
}
public async Task<TResponse> Handle<TRequest, TCommand, TResponse>(TRequest request,
ServerCallContext context)
{
try
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
var cqrsInput = request.Adapt<TCommand>();
if (cqrsInput is null)
{
throw new ArgumentNullException(nameof(cqrsInput));
}
var output = await _sender.Send(cqrsInput, context.CancellationToken);
return (output ?? throw new InvalidOperationException()).Adapt<TResponse>();
}
catch (Exception)
{
throw;
}
}
public async Task<TResponse> Handle<TCommand, TResponse>(ServerCallContext context)
{
try
{
var cqrsInput = Activator.CreateInstance<TCommand>();
if (cqrsInput is null)
{
throw new ArgumentNullException(nameof(cqrsInput));
}
var output = await _sender.Send(cqrsInput, context.CancellationToken);
return (output ?? throw new InvalidOperationException()).Adapt<TResponse>();
}
catch (Exception)
{
throw;
}
}
public async Task<Empty> Handle<TRequest, TCommand>(TRequest request,
ServerCallContext context)
{
try
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
var cqrsInput = request.Adapt<TCommand>();
if (cqrsInput is null)
{
throw new ArgumentNullException(nameof(cqrsInput));
}
await _sender.Send(cqrsInput, context.CancellationToken);
return new Empty();
}
catch (Exception)
{
throw;
}
}
}

View File

@@ -0,0 +1,79 @@
using CMSMicroservice.Application.Common.Interfaces;
using CMSMicroservice.Infrastructure.Persistence;
using CMSMicroservice.WebApi.Common.Services;
using MapsterMapper;
using System.Reflection;
using CMSMicroservice.WebApi.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using System.Linq;
using Microsoft.Extensions.Configuration;
namespace Microsoft.Extensions.DependencyInjection;
public static class ConfigureServices
{
public static IServiceCollection AddPresentationServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddMapping();
services.AddDatabaseDeveloperPageExceptionFilter();
services.AddScoped<ICurrentUserService, CurrentUserService>();
services.AddScoped<IDispatchRequestToCQRS, DispatchRequestToCQRS>();
services.AddHttpContextAccessor();
services.AddHealthChecks()
.AddDbContextCheck<ApplicationDbContext>();
return services;
}
private static IServiceCollection AddMapping(this IServiceCollection services)
{
var typeAdapterConfig = TypeAdapterConfig.GlobalSettings;
// scans the assembly and gets the IRegister, adding the registration to the TypeAdapterConfig
typeAdapterConfig.Scan(Assembly.GetExecutingAssembly());
// register the mapper as Singleton service for my application
var mapperConfig = new Mapper(typeAdapterConfig);
services.AddSingleton<IMapper>(mapperConfig);
return services;
}
// get all grpc endpoint that end with "Service" in specified assembly and register them as grpc client
public static WebApplication ConfigureGrpcEndpoints(this WebApplication app, Assembly? assembly = null,
Action<IEndpointRouteBuilder>? configure = null)
{
if (assembly is not null)
{
var assemblyName = assembly.GetName().Name;
var grpcServices = assembly.GetTypes()
// check name and type
.Where(t => t.Name.EndsWith("Service") && t.IsClass)
// check folder by assembly qualified name
.Where(t => t.AssemblyQualifiedName != null &&
t.AssemblyQualifiedName.Contains($"{assemblyName}.Services"))
// check parent name ends with "ContractBase"
.Where(t => t.BaseType?.Name.EndsWith("ContractBase") == true)
.ToList();
app.UseEndpoints(endpoints =>
{
foreach (var service in grpcServices)
{
// how to use type as generic parameter in csharp?
// https://stackoverflow.com/questions/3957817/calling-generic-method-with-type-variable
var method = typeof(GrpcEndpointRouteBuilderExtensions).GetMethod("MapGrpcService");
var generic = method?.MakeGenericMethod(service);
generic?.Invoke(null, new object[] { endpoints });
}
});
}
if (configure is not null)
{
app.UseEndpoints(configure.Invoke);
}
return app;
}
}

View File

@@ -0,0 +1,27 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["CMSMicroservice.WebApi/CMSMicroservice.WebApi.csproj", "CMSMicroservice.WebApi/"]
COPY ["CMSMicroservice.Application/CMSMicroservice.Application.csproj", "CMSMicroservice.Application/"]
COPY ["CMSMicroservice.Domain/CMSMicroservice.Domain.csproj", "CMSMicroservice.Domain/"]
COPY ["CMSMicroservice.Infrastructure/CMSMicroservice.Infrastructure.csproj", "CMSMicroservice.Infrastructure/"]
COPY ["CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj", "CMSMicroservice.Protobuf/"]
RUN dotnet restore "CMSMicroservice.WebApi/CMSMicroservice.WebApi.csproj"
COPY . .
WORKDIR "/src/CMSMicroservice.WebApi"
RUN dotnet build "CMSMicroservice.WebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "CMSMicroservice.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CMSMicroservice.WebApi.dll"]

View File

@@ -0,0 +1,7 @@
global using Google.Protobuf.WellKnownTypes;
global using Grpc.Core;
global using Mapster;
global using MediatR;
global using System.Threading;
global using System.Threading.Tasks;
global using System;

View File

@@ -0,0 +1,131 @@
using System.Runtime.InteropServices;
using CMSMicroservice.WebApi.Services;
using CMSMicroservice.Infrastructure.Persistence;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Serilog.Core;
using Serilog;
using Serilog.Sinks.MSSqlServer;
using Microsoft.Extensions.Configuration;
using System.Reflection;
using Microsoft.OpenApi.Models;
using CMSMicroservice.WebApi.Common.Behaviours;
var builder = WebApplication.CreateBuilder(args);
var levelSwitch = new LoggingLevelSwitch();
var logger = new LoggerConfiguration()
//.WriteTo.Console()
.WriteTo.MSSqlServer(builder.Configuration.GetConnectionString("LogConnection"),
sinkOptions: new MSSqlServerSinkOptions
{
TableName = "LogCMSEvents",
SchemaName = "Log",
AutoCreateSqlTable = true
})
/* .WriteTo.Seq("http://localhost:5341",
apiKey: "IeEfKjIMoCGLljdp9e7A",
controlLevelSwitch: levelSwitch)*/
.CreateLogger();
builder.Logging.AddSerilog(logger);
#if DEBUG
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));
#endif
// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
// Add services to the container.
builder.Services.AddGrpc(options =>
{
options.Interceptors.Add<LoggingBehaviour>();
options.Interceptors.Add<PerformanceBehaviour>();
options.EnableDetailedErrors = true;
options.MaxReceiveMessageSize = 1000 * 1024 * 1024; // 1 GB
options.MaxSendMessageSize = 1000 * 1024 * 1024; // 1 GB
}).AddJsonTranscoding();
builder.Services.AddApplicationServices();
builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.AddPresentationServices(builder.Configuration);
builder.Services.AddProtobufServices();
#region Configure Cors
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().WithExposedHeaders("Grpc-Status",
"Grpc-Message", "Grpc-Encoding", "Grpc-Accept-Encoding", "validation-errors-text"));
});
#endregion
builder.Services.AddGrpcSwagger();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "gRPC transcoding", Version = "v1" });
c.CustomSchemaIds(type=>type.ToString());
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please insert JWT with Bearer into field",
Name = "Authorization",
Type = SecuritySchemeType.ApiKey
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[] { }
}
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint();
// Initialise and seed database
using (var scope = app.Services.CreateScope())
{
var initialiser = scope.ServiceProvider.GetRequiredService<ApplicationDbContextInitialiser>();
await initialiser.InitialiseAsync();
await initialiser.SeedAsync();
}
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseRouting();
app.UseCors("AllowAll");
app.UseAuthentication();
app.UseAuthorization();
app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true }); // Configure the HTTP request pipeline.
app.ConfigureGrpcEndpoints(Assembly.GetExecutingAssembly(), endpoints =>
{
// endpoints.MapGrpcService<ExampleService>();
});
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.Run();

View File

@@ -0,0 +1,37 @@
using CMSMicroservice.Protobuf.Protos.Package;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.PackageCQ.Commands.CreateNewPackage;
using CMSMicroservice.Application.PackageCQ.Commands.UpdatePackage;
using CMSMicroservice.Application.PackageCQ.Commands.DeletePackage;
using CMSMicroservice.Application.PackageCQ.Queries.GetPackage;
using CMSMicroservice.Application.PackageCQ.Queries.GetAllPackageByFilter;
namespace CMSMicroservice.WebApi.Services;
public class PackageService : PackageContract.PackageContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public PackageService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewPackageResponse> CreateNewPackage(CreateNewPackageRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewPackageRequest, CreateNewPackageCommand, CreateNewPackageResponse>(request, context);
}
public override async Task<Empty> UpdatePackage(UpdatePackageRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdatePackageRequest, UpdatePackageCommand>(request, context);
}
public override async Task<Empty> DeletePackage(DeletePackageRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeletePackageRequest, DeletePackageCommand>(request, context);
}
public override async Task<GetPackageResponse> GetPackage(GetPackageRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetPackageRequest, GetPackageQuery, GetPackageResponse>(request, context);
}
public override async Task<GetAllPackageByFilterResponse> GetAllPackageByFilter(GetAllPackageByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllPackageByFilterRequest, GetAllPackageByFilterQuery, GetAllPackageByFilterResponse>(request, context);
}
}

View File

@@ -0,0 +1,37 @@
using CMSMicroservice.Protobuf.Protos.Role;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.RoleCQ.Commands.CreateNewRole;
using CMSMicroservice.Application.RoleCQ.Commands.UpdateRole;
using CMSMicroservice.Application.RoleCQ.Commands.DeleteRole;
using CMSMicroservice.Application.RoleCQ.Queries.GetRole;
using CMSMicroservice.Application.RoleCQ.Queries.GetAllRoleByFilter;
namespace CMSMicroservice.WebApi.Services;
public class RoleService : RoleContract.RoleContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public RoleService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewRoleResponse> CreateNewRole(CreateNewRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewRoleRequest, CreateNewRoleCommand, CreateNewRoleResponse>(request, context);
}
public override async Task<Empty> UpdateRole(UpdateRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateRoleRequest, UpdateRoleCommand>(request, context);
}
public override async Task<Empty> DeleteRole(DeleteRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeleteRoleRequest, DeleteRoleCommand>(request, context);
}
public override async Task<GetRoleResponse> GetRole(GetRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetRoleRequest, GetRoleQuery, GetRoleResponse>(request, context);
}
public override async Task<GetAllRoleByFilterResponse> GetAllRoleByFilter(GetAllRoleByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllRoleByFilterRequest, GetAllRoleByFilterQuery, GetAllRoleByFilterResponse>(request, context);
}
}

View File

@@ -0,0 +1,37 @@
using CMSMicroservice.Protobuf.Protos.UserAddress;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserAddressCQ.Commands.CreateNewUserAddress;
using CMSMicroservice.Application.UserAddressCQ.Commands.UpdateUserAddress;
using CMSMicroservice.Application.UserAddressCQ.Commands.DeleteUserAddress;
using CMSMicroservice.Application.UserAddressCQ.Queries.GetUserAddress;
using CMSMicroservice.Application.UserAddressCQ.Queries.GetAllUserAddressByFilter;
namespace CMSMicroservice.WebApi.Services;
public class UserAddressService : UserAddressContract.UserAddressContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public UserAddressService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewUserAddressResponse> CreateNewUserAddress(CreateNewUserAddressRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewUserAddressRequest, CreateNewUserAddressCommand, CreateNewUserAddressResponse>(request, context);
}
public override async Task<Empty> UpdateUserAddress(UpdateUserAddressRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateUserAddressRequest, UpdateUserAddressCommand>(request, context);
}
public override async Task<Empty> DeleteUserAddress(DeleteUserAddressRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeleteUserAddressRequest, DeleteUserAddressCommand>(request, context);
}
public override async Task<GetUserAddressResponse> GetUserAddress(GetUserAddressRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetUserAddressRequest, GetUserAddressQuery, GetUserAddressResponse>(request, context);
}
public override async Task<GetAllUserAddressByFilterResponse> GetAllUserAddressByFilter(GetAllUserAddressByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllUserAddressByFilterRequest, GetAllUserAddressByFilterQuery, GetAllUserAddressByFilterResponse>(request, context);
}
}

View File

@@ -0,0 +1,37 @@
using CMSMicroservice.Protobuf.Protos.UserOrder;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserOrderCQ.Commands.CreateNewUserOrder;
using CMSMicroservice.Application.UserOrderCQ.Commands.UpdateUserOrder;
using CMSMicroservice.Application.UserOrderCQ.Commands.DeleteUserOrder;
using CMSMicroservice.Application.UserOrderCQ.Queries.GetUserOrder;
using CMSMicroservice.Application.UserOrderCQ.Queries.GetAllUserOrderByFilter;
namespace CMSMicroservice.WebApi.Services;
public class UserOrderService : UserOrderContract.UserOrderContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public UserOrderService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewUserOrderResponse> CreateNewUserOrder(CreateNewUserOrderRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewUserOrderRequest, CreateNewUserOrderCommand, CreateNewUserOrderResponse>(request, context);
}
public override async Task<Empty> UpdateUserOrder(UpdateUserOrderRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateUserOrderRequest, UpdateUserOrderCommand>(request, context);
}
public override async Task<Empty> DeleteUserOrder(DeleteUserOrderRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeleteUserOrderRequest, DeleteUserOrderCommand>(request, context);
}
public override async Task<GetUserOrderResponse> GetUserOrder(GetUserOrderRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetUserOrderRequest, GetUserOrderQuery, GetUserOrderResponse>(request, context);
}
public override async Task<GetAllUserOrderByFilterResponse> GetAllUserOrderByFilter(GetAllUserOrderByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllUserOrderByFilterRequest, GetAllUserOrderByFilterQuery, GetAllUserOrderByFilterResponse>(request, context);
}
}

View File

@@ -0,0 +1,37 @@
using CMSMicroservice.Protobuf.Protos.UserRole;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserRoleCQ.Commands.CreateNewUserRole;
using CMSMicroservice.Application.UserRoleCQ.Commands.UpdateUserRole;
using CMSMicroservice.Application.UserRoleCQ.Commands.DeleteUserRole;
using CMSMicroservice.Application.UserRoleCQ.Queries.GetUserRole;
using CMSMicroservice.Application.UserRoleCQ.Queries.GetAllUserRoleByFilter;
namespace CMSMicroservice.WebApi.Services;
public class UserRoleService : UserRoleContract.UserRoleContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public UserRoleService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewUserRoleResponse> CreateNewUserRole(CreateNewUserRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewUserRoleRequest, CreateNewUserRoleCommand, CreateNewUserRoleResponse>(request, context);
}
public override async Task<Empty> UpdateUserRole(UpdateUserRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateUserRoleRequest, UpdateUserRoleCommand>(request, context);
}
public override async Task<Empty> DeleteUserRole(DeleteUserRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeleteUserRoleRequest, DeleteUserRoleCommand>(request, context);
}
public override async Task<GetUserRoleResponse> GetUserRole(GetUserRoleRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetUserRoleRequest, GetUserRoleQuery, GetUserRoleResponse>(request, context);
}
public override async Task<GetAllUserRoleByFilterResponse> GetAllUserRoleByFilter(GetAllUserRoleByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllUserRoleByFilterRequest, GetAllUserRoleByFilterQuery, GetAllUserRoleByFilterResponse>(request, context);
}
}

View File

@@ -0,0 +1,37 @@
using CMSMicroservice.Protobuf.Protos.User;
using CMSMicroservice.WebApi.Common.Services;
using CMSMicroservice.Application.UserCQ.Commands.CreateNewUser;
using CMSMicroservice.Application.UserCQ.Commands.UpdateUser;
using CMSMicroservice.Application.UserCQ.Commands.DeleteUser;
using CMSMicroservice.Application.UserCQ.Queries.GetUser;
using CMSMicroservice.Application.UserCQ.Queries.GetAllUserByFilter;
namespace CMSMicroservice.WebApi.Services;
public class UserService : UserContract.UserContractBase
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
public UserService(IDispatchRequestToCQRS dispatchRequestToCQRS)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
}
public override async Task<CreateNewUserResponse> CreateNewUser(CreateNewUserRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<CreateNewUserRequest, CreateNewUserCommand, CreateNewUserResponse>(request, context);
}
public override async Task<Empty> UpdateUser(UpdateUserRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<UpdateUserRequest, UpdateUserCommand>(request, context);
}
public override async Task<Empty> DeleteUser(DeleteUserRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<DeleteUserRequest, DeleteUserCommand>(request, context);
}
public override async Task<GetUserResponse> GetUser(GetUserRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetUserRequest, GetUserQuery, GetUserResponse>(request, context);
}
public override async Task<GetAllUserByFilterResponse> GetAllUserByFilter(GetAllUserByFilterRequest request, ServerCallContext context)
{
return await _dispatchRequestToCQRS.Handle<GetAllUserByFilterRequest, GetAllUserByFilterQuery, GetAllUserByFilterResponse>(request, context);
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Grpc": "Information",
"Microsoft": "Information"
}
}
}

View File

@@ -0,0 +1,17 @@
{
"ConnectionStrings": {
"LogConnection": "Data Source=.,2019; Initial Catalog=DBName;User ID=dbuser;Password=dbpassword;Connection Timeout=300000;MultipleActiveResultSets=True;Encrypt=False",
"DefaultConnection": "Data Source=.,2019; Initial Catalog=DBName;User ID=dbuser;Password=dbpassword;Connection Timeout=300000;MultipleActiveResultSets=True;Encrypt=False",
"providerName": "System.Data.SqlClient"
},
"AllowedHosts": "*",
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
},
"Authentication": {
"Authority": "https://ids.domain.com/",
"Audience": "domain_api"
}
}