add marten
parent
879b59f0bd
commit
24ca6e859c
|
@ -2,6 +2,7 @@
|
|||
"ConnectionStrings": {
|
||||
"PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
||||
"Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS",
|
||||
"Marten": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopSettingsDB;",
|
||||
"SettingDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopSettingDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS"
|
||||
},
|
||||
"Logging": {
|
||||
|
|
|
@ -51,8 +51,7 @@ public class OrderBagController : ICarterModule
|
|||
=> TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken));
|
||||
|
||||
public async Task<IResult> AddShippingToOrderBagAsync(Guid orderId, [FromBody] SubmitOrderDeliveryCommand request, IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok( await mediator.Send(new SubmitOrderDeliveryCommand(request.Address, request.PostalCode,
|
||||
request.ReceiverPhoneNumber, request.ReceiverFullName, orderId, request.ShippingId), cancellationToken));
|
||||
=> TypedResults.Ok( await mediator.Send(new SubmitOrderDeliveryCommand(request.AddressId, orderId, request.ShippingId), cancellationToken));
|
||||
|
||||
public async Task<IResult> SubmitOrderPaymentAsync(Guid orderId, [FromQuery] OrderPaymentMethod paymentMethod, IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok( await mediator.Send(new SubmitOrderPaymentCommand(orderId, paymentMethod), cancellationToken));
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
using NetinaShop.Repository.Repositories.Entity.Abstracts;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace NetinaShop.Api.Controller;
|
||||
|
||||
public class PageController : ICarterModule
|
||||
{
|
||||
public void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("Pages")
|
||||
.MapGroup("api/page");
|
||||
|
||||
group.MapGet("", GetPagesAsync)
|
||||
.WithDisplayName("Get Pages")
|
||||
.HasApiVersion(1.0)
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
|
||||
group.MapGet("{id}", GetPageByIdAsync)
|
||||
.WithDisplayName("Get Page")
|
||||
.HasApiVersion(1.0)
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("slug/{pageSlug}", GetPageAsync)
|
||||
.WithDisplayName("Get Page")
|
||||
.HasApiVersion(1.0)
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("type/{type}", GetPageByTypeAsync)
|
||||
.WithDisplayName("Get Page")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", PostPageAsync)
|
||||
.WithDisplayName("Post Page")
|
||||
.HasApiVersion(1.0)
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
}
|
||||
public async Task<IResult> GetPagesAsync(Guid id, [FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
{
|
||||
return TypedResults.Ok(await pageService.GetPagesAsync(cancellationToken));
|
||||
}
|
||||
|
||||
public async Task<IResult> GetPageByIdAsync(Guid id ,[FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
{
|
||||
return TypedResults.Ok(await pageService.GetPageAsync(id: id,cancellationToken: cancellationToken));
|
||||
}
|
||||
public async Task<IResult> GetPageByTypeAsync(string type, [FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
{
|
||||
return TypedResults.Ok(await pageService.GetPageAsync(type: type, cancellationToken: cancellationToken));
|
||||
}
|
||||
|
||||
public async Task<IResult> GetPageAsync(string pageSlug, [FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
{
|
||||
return TypedResults.Ok(await pageService.GetPageAsync(pageSlug: pageSlug,cancellationToken: cancellationToken));
|
||||
}
|
||||
|
||||
public async Task<IResult> PostPageAsync([FromBody] PageActionRequestDto page, [FromServices] IPageService pageService, CancellationToken cancellationToken)
|
||||
{
|
||||
await pageService.CreatePageAsync(page, cancellationToken);
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using NetinaShop.Repository.Repositories.Entity.Abstracts;
|
||||
|
||||
namespace NetinaShop.Api.Controller;
|
||||
|
||||
public class SettingController : ICarterModule
|
||||
{
|
||||
public void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("Setting")
|
||||
.MapGroup("api/setting")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("{settingName}", GetSettingAsync)
|
||||
.WithDisplayName("GetSetting")
|
||||
.HasApiVersion(1.0);
|
||||
group.MapPost("{settingName}", PostSettingAsync)
|
||||
.WithDisplayName("PostSettingAsync")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
public async Task<IResult> GetSettingAsync(string settingName, [FromServices] IMartenRepository martenRepository, CancellationToken cancellationToken)
|
||||
{
|
||||
var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType($"NetinaShop.Domain.Entities.Settings.{settingName}");
|
||||
if (type == null)
|
||||
throw new AppException("Setting not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
var setting = await ((dynamic)martenRepository.GetType()?.GetMethod("GetEntityAsync")
|
||||
?.MakeGenericMethod(type)
|
||||
.Invoke(martenRepository,new object[]{ cancellationToken })!);
|
||||
if (setting == null)
|
||||
setting = Activator.CreateInstance(type);
|
||||
|
||||
return TypedResults.Ok(setting);
|
||||
}
|
||||
|
||||
public async Task<IResult> PostSettingAsync(string settingName, [FromBody]JsonDocument settingObj, [FromServices] IMartenRepository martenRepository, CancellationToken cancellationToken)
|
||||
{
|
||||
var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType($"NetinaShop.Domain.Entities.Settings.{settingName}");
|
||||
if (type == null)
|
||||
throw new AppException("Setting not found", ApiResultStatusCode.NotFound);
|
||||
var setting = settingObj.Deserialize(type);
|
||||
if (setting == null)
|
||||
throw new AppException("Setting not found", ApiResultStatusCode.NotFound);
|
||||
await ((dynamic)martenRepository.GetType().GetMethod("AddOrUpdateEntityAsync")
|
||||
?.MakeGenericMethod(type).Invoke(martenRepository, new[] { setting , cancellationToken })!);
|
||||
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
namespace NetinaShop.Api.Controller;
|
||||
|
||||
public class UserAddressController : ICarterModule
|
||||
{
|
||||
public void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("UserAddress")
|
||||
.MapGroup("api/user/address")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("", GetAddressesAsync)
|
||||
.WithDisplayName("Get Addresses")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", PostAddressesAsync)
|
||||
.WithDisplayName("Post Addresses")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapDelete("{id}", DeleteAddressesAsync)
|
||||
.WithDisplayName("Delete Address")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
public async Task<IResult> GetAddressesAsync([FromServices] IMediator mediator,CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetUserAddressesQuery(null), cancellationToken));
|
||||
|
||||
public async Task<IResult> PostAddressesAsync([FromBody] CreateAddressCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
|
||||
|
||||
public async Task<IResult> DeleteAddressesAsync(Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new DeleteAddressCommand(id), cancellationToken));
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using NetinaShop.Core.EntityServices.Abstracts;
|
||||
using NetinaShop.Repository.Abstracts;
|
||||
|
||||
namespace NetinaShop.Api.Controller;
|
||||
|
||||
|
@ -12,6 +14,10 @@ public class UserController : ICarterModule
|
|||
.MapGroup($"api/user")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("info", GetUserInfoAsync)
|
||||
.WithDisplayName("GetUserInfo")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("", GetAllAsync)
|
||||
.WithDisplayName("GetAllUsers")
|
||||
.HasApiVersion(1.0);
|
||||
|
@ -30,6 +36,13 @@ public class UserController : ICarterModule
|
|||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
public async Task<IResult> GetUserInfoAsync(IUserService userService,ICurrentUserService currentUserService, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (!Guid.TryParse(currentUserService.UserId, out var userId))
|
||||
throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized);
|
||||
return TypedResults.Ok(await userService.GetUserAsync(userId, cancellationToken));
|
||||
}
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> GetAllAsync([FromQuery] int page, [FromQuery]string? phoneNumber, IUserService userService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await userService.GetUsersAsync(page,phoneNumber,cancellationToken));
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
|
||||
<PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="12.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
@ -37,7 +37,6 @@
|
|||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
|
||||
<PackageReference Include="Sentry.Serilog" Version="4.0.1" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
||||
|
|
|
@ -36,6 +36,7 @@ builder.Services.AddJwtCustomAuthentication(siteSetting.JwtSettings);
|
|||
builder.Services.AddMvcCore().AddRazorPages().AddRazorViewEngine().AddViews();
|
||||
builder.Services.AddCustomIdentity();
|
||||
builder.Services.AddCustomDbContext(configuration);
|
||||
builder.Services.AddMarten(configuration,builder.Environment);
|
||||
builder.Services.AddCarter();
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
namespace NetinaShop.Api.WebFramework.Configurations;
|
||||
using Marten;
|
||||
using Weasel.Core;
|
||||
|
||||
namespace NetinaShop.Api.WebFramework.Configurations;
|
||||
|
||||
public static class ServiceExtensions
|
||||
{
|
||||
|
@ -58,6 +61,22 @@ public static class ServiceExtensions
|
|||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
public static void AddMarten(this IServiceCollection serviceCollection, IConfigurationRoot configuration , IWebHostEnvironment environment)
|
||||
{
|
||||
serviceCollection.AddMarten(options =>
|
||||
{
|
||||
// Establish the connection string to your Marten database
|
||||
options.Connection(configuration.GetConnectionString("Marten")!);
|
||||
|
||||
// If we're running in development mode, let Marten just take care
|
||||
// of all necessary schema building and patching behind the scenes
|
||||
if (environment.IsDevelopment())
|
||||
{
|
||||
options.AutoCreateSchemaObjects = AutoCreate.All;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddCustomResponseCompression(this IServiceCollection serviceCollection)
|
||||
{
|
||||
serviceCollection.Configure<GzipCompressionProviderOptions>(options =>
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace NetinaShop.Common.Extensions
|
|||
|
||||
foreach (var attr in attrs)
|
||||
{
|
||||
var displayAttribute = attr as ClassDisplay;
|
||||
var displayAttribute = attr as PageClassDisplay;
|
||||
if (displayAttribute == null)
|
||||
continue;
|
||||
return displayAttribute.GetName();
|
||||
|
@ -27,7 +27,7 @@ namespace NetinaShop.Common.Extensions
|
|||
|
||||
foreach (var attr in attrs)
|
||||
{
|
||||
var displayAttribute = attr as ClassDisplay;
|
||||
var displayAttribute = attr as PageClassDisplay;
|
||||
if (displayAttribute == null)
|
||||
continue;
|
||||
return displayAttribute.GetDescription();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
namespace NetinaShop.Common.Models.Entity
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ClassDisplay : Attribute
|
||||
public class PageClassDisplay : Attribute
|
||||
{
|
||||
private readonly string _description;
|
||||
private readonly string _name;
|
||||
|
||||
public ClassDisplay(string name, string description)
|
||||
public PageClassDisplay(string name, string description)
|
||||
{
|
||||
_name = name;
|
||||
_description = description;
|
|
@ -0,0 +1,10 @@
|
|||
using NetinaShop.Domain.Entities.Pages;
|
||||
|
||||
namespace NetinaShop.Core.CoreServices.Abstracts;
|
||||
|
||||
public interface IPageService : IScopedDependency
|
||||
{
|
||||
Task<BasePageEntitySDto> GetPageAsync(Guid? id = null, string? pageName = null, string? pageSlug = null,string? type = null, CancellationToken cancellationToken=default);
|
||||
Task<List<BasePageEntitySDto>> GetPagesAsync(CancellationToken cancellationToken = default);
|
||||
Task<bool> CreatePageAsync(PageActionRequestDto entity, CancellationToken cancellationToken = default);
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using NetinaShop.Domain.Entities.Pages;
|
||||
using NetinaShop.Repository.Repositories.Entity.Abstracts;
|
||||
|
||||
namespace NetinaShop.Core.CoreServices;
|
||||
|
||||
public class PageService : IPageService
|
||||
{
|
||||
private readonly IMartenRepository _martenRepository;
|
||||
|
||||
public PageService(IMartenRepository martenRepository)
|
||||
{
|
||||
_martenRepository = martenRepository;
|
||||
}
|
||||
public async Task<BasePageEntitySDto> GetPageAsync(Guid? id = null, string? pageName = null, string? pageSlug = null, string? type = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
BasePageEntity? page = null;
|
||||
if (id != null)
|
||||
page = await _martenRepository.GetEntityAsync<BasePageEntity>(id.Value, cancellationToken);
|
||||
else if (pageSlug != null)
|
||||
page = await _martenRepository.GetEntityAsync<BasePageEntity>(entity => entity.Slug == pageSlug, cancellationToken);
|
||||
else if (pageName != null)
|
||||
page = await _martenRepository.GetEntityAsync<BasePageEntity>(entity => entity.Name == pageName, cancellationToken);
|
||||
else if (type != null)
|
||||
page = await _martenRepository.GetEntityAsync<BasePageEntity>(entity => entity.Type == type, cancellationToken);
|
||||
if (page == null)
|
||||
throw new AppException("Page not found",ApiResultStatusCode.NotFound);
|
||||
|
||||
var dto = new BasePageEntitySDto
|
||||
{
|
||||
|
||||
Content = page.Content,
|
||||
Description = page.Description,
|
||||
Id = page.Id,
|
||||
IsCustomPage = page.IsCustomPage,
|
||||
IsHtmlBasePage = page.IsHtmlBasePage,
|
||||
Name = page.Name,
|
||||
Slug = page.Slug,
|
||||
Data = JsonConvert.DeserializeObject(page.Data)
|
||||
};
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<List<BasePageEntitySDto>> GetPagesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
List<BasePageEntitySDto> sDtos = new List<BasePageEntitySDto>();
|
||||
var pages = await _martenRepository.GetEntitiesAsync<BasePageEntity>(cancellationToken);
|
||||
foreach (var page in pages)
|
||||
{
|
||||
var dto = new BasePageEntitySDto
|
||||
{
|
||||
|
||||
Content = page.Content,
|
||||
Description = page.Description,
|
||||
Id = page.Id,
|
||||
IsCustomPage = page.IsCustomPage,
|
||||
IsHtmlBasePage = page.IsHtmlBasePage,
|
||||
Name = page.Name,
|
||||
Slug = page.Slug,
|
||||
Data = JsonConvert.DeserializeObject(page.Data)
|
||||
};
|
||||
sDtos.Add(dto);
|
||||
}
|
||||
return sDtos;
|
||||
}
|
||||
|
||||
public async Task<bool> CreatePageAsync(PageActionRequestDto entity, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var basePage = new BasePageEntity
|
||||
{
|
||||
Content = entity.Content,
|
||||
Description = entity.Description,
|
||||
Id = entity.Id,
|
||||
IsCustomPage = entity.IsCustomPage,
|
||||
IsHtmlBasePage = entity.IsHtmlBasePage,
|
||||
Name = entity.Name,
|
||||
Type = entity.Type,
|
||||
Slug = entity.Slug,
|
||||
Data = JsonConvert.SerializeObject(entity.Data)
|
||||
};
|
||||
await _martenRepository.AddOrUpdateEntityAsync(basePage, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace NetinaShop.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountCommand,bool>
|
||||
public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountCommand,OrderSDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly IMediator _mediator;
|
||||
|
@ -10,7 +10,7 @@ public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountComman
|
|||
_repositoryWrapper = repositoryWrapper;
|
||||
_mediator = mediator;
|
||||
}
|
||||
public async Task<bool> Handle(SubmitDiscountCommand request, CancellationToken cancellationToken)
|
||||
public async Task<OrderSDto> Handle(SubmitDiscountCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var order = await _repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
|
@ -25,8 +25,8 @@ public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountComman
|
|||
order.SetDiscount(request.DiscountCode);
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
|
||||
var calculateOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
|
||||
|
||||
return true;
|
||||
return calculateOrder.AdaptToSDto();
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace NetinaShop.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeliveryCommand,bool>
|
||||
public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeliveryCommand, OrderSDto>
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
@ -12,7 +12,7 @@ public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeli
|
|||
_mediator = mediator;
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken)
|
||||
public async Task<OrderSDto> Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken);
|
||||
var shipping = await _repositoryWrapper.SetRepository<Shipping>()
|
||||
|
@ -20,18 +20,27 @@ public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeli
|
|||
.FirstOrDefaultAsync(s => s.Id == request.ShippingId, cancellationToken);
|
||||
if (shipping == null)
|
||||
throw new AppException("Shipping not found", ApiResultStatusCode.NotFound);
|
||||
foreach (var orderDelivery in order.OrderDeliveries)
|
||||
if (order.OrderDeliveries.Count > 0)
|
||||
{
|
||||
_repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.Delete(orderDelivery);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
foreach (var orderDelivery in order.OrderDeliveries)
|
||||
{
|
||||
var newEnt = OrderDelivery.Create(request.AddressId, shipping.DeliveryCost, request.ShippingId,
|
||||
request.OrderId);
|
||||
newEnt.CreatedAt = orderDelivery.CreatedAt;
|
||||
newEnt.CreatedBy = orderDelivery.CreatedBy;
|
||||
newEnt.Id = orderDelivery.Id;
|
||||
_repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.Update(newEnt);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
order.OrderDeliveries.Clear();
|
||||
}
|
||||
order.OrderDeliveries.Clear();
|
||||
order.AddOrderDelivery(request.Address,request.PostalCode,request.ReceiverPhoneNumber,request.ReceiverFullName,shipping.DeliveryCost,request.ShippingId,request.OrderId);
|
||||
else
|
||||
order.AddOrderDelivery(request.AddressId, shipping.DeliveryCost, request.ShippingId, request.OrderId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
|
||||
return true;
|
||||
var calculatedOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
|
||||
return calculatedOrder.AdaptToSDto();
|
||||
}
|
||||
}
|
|
@ -35,7 +35,8 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
var taxesPrice = 0;
|
||||
|
||||
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice);
|
||||
|
||||
order.OrderProducts.Clear();
|
||||
order.OrderDeliveries.Clear();
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return order;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
namespace NetinaShop.Domain.CommandQueries.Commands;
|
||||
|
||||
public sealed record CreateAddressCommand(
|
||||
string Address,
|
||||
string Province,
|
||||
string City,
|
||||
string Plaque,
|
||||
string BuildingUnit,
|
||||
string ReceiverFullName,
|
||||
string ReceiverPhoneNumber,
|
||||
string PostalCode,
|
||||
float LocationLat,
|
||||
float LocationLong) : IRequest<bool>;
|
||||
|
||||
public sealed record UpdateAddressCommand(
|
||||
Guid Id,
|
||||
string Address,
|
||||
string Province,
|
||||
string City,
|
||||
string Plaque,
|
||||
string BuildingUnit,
|
||||
string ReceiverFullName,
|
||||
string ReceiverPhoneNumber,
|
||||
string PostalCode,
|
||||
float LocationLat,
|
||||
float LocationLong) : IRequest<bool>;
|
||||
|
||||
public sealed record DeleteAddressCommand(Guid Id):IRequest<bool>;
|
|
@ -7,8 +7,8 @@ public sealed record CreateOrderCommand(string DiscountCode, List<OrderProductSD
|
|||
public sealed record AddToOrderBagCommand(List<OrderBagRequestDto> RequestDtos) : IRequest<OrderSDto>;
|
||||
public sealed record RemoveFromOrderBagCommand(List<OrderBagRequestDto> RequestDtos) : IRequest<OrderSDto>;
|
||||
|
||||
public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest<bool>;
|
||||
public sealed record SubmitOrderDeliveryCommand(string Address, string PostalCode, string ReceiverPhoneNumber, string ReceiverFullName, Guid OrderId, Guid ShippingId) : IRequest<bool>;
|
||||
public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest<OrderSDto>;
|
||||
public sealed record SubmitOrderDeliveryCommand(Guid AddressId, Guid OrderId, Guid ShippingId) : IRequest<OrderSDto>;
|
||||
|
||||
public sealed record SubmitOrderPaymentCommand(Guid OrderId, OrderPaymentMethod PaymentMethod , bool HasPaid = false) : IRequest<SubmitOrderPaymentResponseDto>;
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ public sealed record CreateShippingCommand (
|
|||
bool IsExpressShipping,
|
||||
bool IsShipBySeller ,
|
||||
bool IsOriginalWarehouse,
|
||||
double DeliveryCost) : IRequest<ShippingSDto>;
|
||||
double DeliveryCost,
|
||||
int WorkingDays) : IRequest<ShippingSDto>;
|
||||
|
||||
public sealed record UpdateShippingCommand(
|
||||
Guid Id,
|
||||
|
@ -15,7 +16,8 @@ public sealed record UpdateShippingCommand(
|
|||
bool IsExpressShipping,
|
||||
bool IsShipBySeller,
|
||||
bool IsOriginalWarehouse,
|
||||
double DeliveryCost) : IRequest<bool>;
|
||||
double DeliveryCost,
|
||||
int WorkingDays) : IRequest<bool>;
|
||||
|
||||
public sealed record DeleteShippingCommand(
|
||||
Guid Id) : IRequest<bool>;
|
|
@ -0,0 +1,4 @@
|
|||
namespace NetinaShop.Domain.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetAddressesQuery():IRequest<List<UserAddressSDto>>;
|
||||
public sealed record GetUserAddressesQuery(Guid? UserId) : IRequest<List<UserAddressSDto>>;
|
|
@ -0,0 +1,14 @@
|
|||
namespace NetinaShop.Domain.Dtos.RequestDtos;
|
||||
|
||||
public class PageActionRequestDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Content { get; set; } = string.Empty;
|
||||
public bool IsCustomPage { get; set; }
|
||||
public bool IsHtmlBasePage { get; set; }
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public object? Data { get; set; }
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using NetinaShop.Domain.Entities.Pages;
|
||||
|
||||
namespace NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class BasePageEntitySDto : BaseDto<BasePageEntitySDto,BasePageEntity>
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Content { get; set; } = string.Empty;
|
||||
public bool IsCustomPage { get; set; }
|
||||
public bool IsHtmlBasePage { get; set; }
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
public object? Data { get; set; }
|
||||
}
|
|
@ -2,11 +2,18 @@
|
|||
|
||||
public class OrderDeliverySDto : BaseDto<OrderDeliverySDto, OrderDelivery>
|
||||
{
|
||||
public string Province { get; set; } = string.Empty;
|
||||
public string City { get; set; } = string.Empty;
|
||||
public string Plaque { get; set; } = string.Empty;
|
||||
public float LocationLat { get; set; }
|
||||
public float LocationLong { get; set; }
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public string PostalCode { get; set; } = string.Empty;
|
||||
public string ReceiverPhoneNumber { get; set; } = string.Empty;
|
||||
public string ReceiverFullName { get; set; } = string.Empty;
|
||||
public string ShippingMethod { get; set; } = string.Empty;
|
||||
public double DeliveryCost { get; internal set; }
|
||||
public Guid AddressId { get; set; }
|
||||
public Guid OrderId { get; set; }
|
||||
public Guid ShippingId { get; internal set; }
|
||||
}
|
||||
|
|
|
@ -8,4 +8,5 @@ public class ShippingSDto : BaseDto<ShippingSDto,Shipping>
|
|||
public bool IsShipBySeller { get; set; }
|
||||
public bool IsOriginalWarehouse { get; set; }
|
||||
public double DeliveryCost { get; set; }
|
||||
public int WorkingDays { get; set; }
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
namespace NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class UserAddressSDto : BaseDto<UserAddressSDto,UserAddress>
|
||||
{
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public string PostalCode { get; set; } = string.Empty;
|
||||
public string ReceiverFullName { get; set; } = string.Empty;
|
||||
public string ReceiverPhoneNumber { get; set; } = string.Empty;
|
||||
public float LocationLat { get; set; }
|
||||
public float LocationLong { get; set; }
|
||||
public string Province { get; set; } = string.Empty;
|
||||
public string City { get; set; } = string.Empty;
|
||||
public string Plaque { get; set; } = string.Empty;
|
||||
public string BuildingUnit { get; set; } = string.Empty;
|
||||
public Guid UserId { get; set; }
|
||||
}
|
|
@ -72,9 +72,9 @@ public partial class Order
|
|||
}
|
||||
}
|
||||
|
||||
public void AddOrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId)
|
||||
public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId)
|
||||
{
|
||||
var orderDelivery = OrderDelivery.Create(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId);
|
||||
var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId);
|
||||
OrderDeliveries.Add(orderDelivery);
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,8 @@ public partial class OrderProduct
|
|||
|
||||
public partial class OrderDelivery
|
||||
{
|
||||
public static OrderDelivery Create(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId)
|
||||
public static OrderDelivery Create(Guid addressId,double deliveryCost, Guid shippingId, Guid orderId)
|
||||
{
|
||||
return new OrderDelivery(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId);
|
||||
return new OrderDelivery(addressId, deliveryCost, shippingId, orderId);
|
||||
}
|
||||
}
|
|
@ -6,20 +6,17 @@ public partial class OrderDelivery : ApiEntity
|
|||
{
|
||||
|
||||
}
|
||||
public OrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId)
|
||||
public OrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId)
|
||||
{
|
||||
Address = address;
|
||||
PostalCode = postalCode;
|
||||
ReceiverPhoneNumber = receiverPhoneNumber;
|
||||
ReceiverFullName = receiverFullName;
|
||||
AddressId = addressId;
|
||||
DeliveryCost = deliveryCost;
|
||||
ShippingId = shippingId;
|
||||
OrderId = orderId;
|
||||
}
|
||||
public string Address { get; internal set; } = string.Empty;
|
||||
public string PostalCode { get; internal set; } = string.Empty;
|
||||
public string ReceiverPhoneNumber { get; internal set; } = string.Empty;
|
||||
public string ReceiverFullName { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid AddressId { get; set; }
|
||||
public UserAddress? Address { get; set; }
|
||||
|
||||
public double DeliveryCost { get; internal set; }
|
||||
public Guid ShippingId { get; internal set; }
|
||||
public Shipping? Shipping { get; internal set; }
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
namespace NetinaShop.Domain.Entities.Pages;
|
||||
|
||||
public class BasePageEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Content { get; set; } = string.Empty;
|
||||
public bool IsCustomPage { get; set; }
|
||||
public bool IsHtmlBasePage { get; set; }
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public string Data { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace NetinaShop.Domain.Entities.Pages;
|
||||
|
||||
[PageClassDisplay("FAQPage", "صفحه سوالات متداول")]
|
||||
public class FAQPage
|
||||
{
|
||||
public Dictionary<string, string> Faqs { get; set; } = new Dictionary<string, string>();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace NetinaShop.Domain.Entities.Settings;
|
||||
|
||||
public class PaymentSetting
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string ZarinPalApiKey { get; set; } = string.Empty;
|
||||
public string PayPalApiKey { get; set; } = string.Empty;
|
||||
public string BehPardakhtApiKey { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
namespace NetinaShop.Domain.Entities.Users;
|
||||
|
||||
public partial class UserAddress
|
||||
{
|
||||
public static UserAddress Create(string address, string postalCode, string receiverFullName,
|
||||
string receiverPhoneNumber, float locationLat, float locationLong, string province, string city, string plaque,
|
||||
string buildingUnit, Guid userId)
|
||||
{
|
||||
return new UserAddress(address, postalCode, receiverFullName, receiverPhoneNumber,
|
||||
locationLat, locationLong, province, city, plaque, buildingUnit,
|
||||
userId);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,42 @@
|
|||
namespace NetinaShop.Domain.Entities.Users;
|
||||
|
||||
public class UserAddress : ApiEntity
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
|
||||
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class UserAddress : ApiEntity
|
||||
{
|
||||
public UserAddress()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UserAddress(string address, string postalCode, string receiverFullName, string receiverPhoneNumber,
|
||||
float locationLat, float locationLong, string province, string city, string plaque, string buildingUnit,
|
||||
Guid userId)
|
||||
{
|
||||
Address = address;
|
||||
PostalCode = postalCode;
|
||||
ReceiverFullName = receiverFullName;
|
||||
ReceiverPhoneNumber = receiverPhoneNumber;
|
||||
LocationLat = locationLat;
|
||||
LocationLong = locationLong;
|
||||
Province = province;
|
||||
City = city;
|
||||
Plaque = plaque;
|
||||
BuildingUnit = buildingUnit;
|
||||
UserId = userId;
|
||||
}
|
||||
|
||||
public string Address { get; internal set; } = string.Empty;
|
||||
public string PostalCode { get; internal set; } = string.Empty;
|
||||
public string ReceiverFullName { get; internal set; } = string.Empty;
|
||||
public string ReceiverPhoneNumber { get; internal set; } = string.Empty;
|
||||
public float LocationLat { get; internal set; }
|
||||
public float LocationLong { get; internal set; }
|
||||
public string Province { get; internal set; } = string.Empty;
|
||||
public string City { get; internal set; } = string.Empty;
|
||||
public string Plaque { get; internal set; } = string.Empty;
|
||||
public string BuildingUnit { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid UserId { get; internal set; }
|
||||
public ApplicationUser? User { get; internal set; }
|
||||
|
|
|
@ -9,7 +9,7 @@ public partial class Shipping : ApiEntity
|
|||
{
|
||||
}
|
||||
|
||||
public Shipping(string name, string warehouseName, bool isExpressShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost)
|
||||
public Shipping(string name, string warehouseName, bool isExpressShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost, int workingDays)
|
||||
{
|
||||
Name = name;
|
||||
WarehouseName = warehouseName;
|
||||
|
@ -17,6 +17,7 @@ public partial class Shipping : ApiEntity
|
|||
IsShipBySeller = isShipBySeller;
|
||||
IsOriginalWarehouse = isOriginalWarehouse;
|
||||
DeliveryCost = deliveryCost;
|
||||
WorkingDays = workingDays;
|
||||
}
|
||||
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
|
@ -25,4 +26,5 @@ public partial class Shipping : ApiEntity
|
|||
public bool IsShipBySeller { get; internal set; }
|
||||
public bool IsOriginalWarehouse { get; internal set; }
|
||||
public double DeliveryCost { get; internal set; }
|
||||
public int WorkingDays { get; internal set; }
|
||||
}
|
|
@ -7,8 +7,8 @@ public partial class Warehouses
|
|||
|
||||
public partial class Shipping
|
||||
{
|
||||
public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost)
|
||||
public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost,int workingDays)
|
||||
{
|
||||
return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse,deliveryCost);
|
||||
return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse,deliveryCost, workingDays);
|
||||
}
|
||||
}
|
|
@ -7,5 +7,7 @@ public enum OrderPaymentMethod
|
|||
[Display(Name = "پرداخت انلاین")]
|
||||
OnlinePayment,
|
||||
[Display(Name = "پرداخت کارت به کارت")]
|
||||
CardTransfer
|
||||
CardTransfer,
|
||||
[Display(Name = "نقدی")]
|
||||
Cash,
|
||||
}
|
|
@ -112,10 +112,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
}).ToList<OrderProduct>(),
|
||||
OrderDeliveries = p15.OrderDeliveries.Select<OrderDeliverySDto, OrderDelivery>(p17 => new OrderDelivery()
|
||||
{
|
||||
Address = p17.Address,
|
||||
PostalCode = p17.PostalCode,
|
||||
ReceiverPhoneNumber = p17.ReceiverPhoneNumber,
|
||||
ReceiverFullName = p17.ReceiverFullName,
|
||||
Address = p17.Address == null ? null : (UserAddress)Convert.ChangeType((object)p17.Address, typeof(UserAddress)),
|
||||
ShippingId = p17.ShippingId,
|
||||
Shipping = new Shipping() {Id = p17.ShippingId},
|
||||
OrderId = p17.OrderId,
|
||||
|
@ -242,10 +239,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
}).ToList<OrderProductSDto>(),
|
||||
OrderDeliveries = p31.OrderDeliveries.Select<OrderDelivery, OrderDeliverySDto>(p33 => new OrderDeliverySDto()
|
||||
{
|
||||
Address = p33.Address,
|
||||
PostalCode = p33.PostalCode,
|
||||
ReceiverPhoneNumber = p33.ReceiverPhoneNumber,
|
||||
ReceiverFullName = p33.ReceiverFullName,
|
||||
Address = p33.Address == null ? null : p33.Address.ToString(),
|
||||
ShippingMethod = p33.Shipping != null ? p33.Shipping.Name : string.Empty,
|
||||
OrderId = p33.OrderId,
|
||||
ShippingId = p33.ShippingId,
|
||||
|
@ -469,10 +463,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
OrderDeliverySDto item = p3[i];
|
||||
result.Add(item == null ? null : new OrderDelivery()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
Address = item.Address == null ? null : (UserAddress)Convert.ChangeType((object)item.Address, typeof(UserAddress)),
|
||||
ShippingId = item.ShippingId,
|
||||
Shipping = new Shipping() {Id = item.ShippingId},
|
||||
OrderId = item.OrderId,
|
||||
|
@ -593,10 +584,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
OrderDeliverySDto item = p11[i];
|
||||
result.Add(item == null ? null : new OrderDelivery()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
Address = item.Address == null ? null : (UserAddress)Convert.ChangeType((object)item.Address, typeof(UserAddress)),
|
||||
ShippingId = item.ShippingId,
|
||||
Shipping = new Shipping() {Id = item.ShippingId},
|
||||
OrderId = item.OrderId,
|
||||
|
@ -703,10 +691,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
OrderDelivery item = p21[i];
|
||||
result.Add(item == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
Address = item.Address == null ? null : item.Address.ToString(),
|
||||
ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty,
|
||||
OrderId = item.OrderId,
|
||||
ShippingId = item.ShippingId,
|
||||
|
@ -808,10 +793,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
OrderDelivery item = p27[i];
|
||||
result.Add(item == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
Address = item.Address == null ? null : item.Address.ToString(),
|
||||
ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty,
|
||||
OrderId = item.OrderId,
|
||||
ShippingId = item.ShippingId,
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
IsShipBySeller = p1.IsShipBySeller,
|
||||
IsOriginalWarehouse = p1.IsOriginalWarehouse,
|
||||
DeliveryCost = p1.DeliveryCost,
|
||||
WorkingDays = p1.WorkingDays,
|
||||
Id = p1.Id,
|
||||
CreatedAt = p1.CreatedAt
|
||||
};
|
||||
|
@ -35,6 +36,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.IsShipBySeller = p2.IsShipBySeller;
|
||||
result.IsOriginalWarehouse = p2.IsOriginalWarehouse;
|
||||
result.DeliveryCost = p2.DeliveryCost;
|
||||
result.WorkingDays = p2.WorkingDays;
|
||||
result.Id = p2.Id;
|
||||
result.CreatedAt = p2.CreatedAt;
|
||||
return result;
|
||||
|
@ -50,6 +52,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
IsShipBySeller = p4.IsShipBySeller,
|
||||
IsOriginalWarehouse = p4.IsOriginalWarehouse,
|
||||
DeliveryCost = p4.DeliveryCost,
|
||||
WorkingDays = p4.WorkingDays,
|
||||
Id = p4.Id,
|
||||
CreatedAt = p4.CreatedAt
|
||||
};
|
||||
|
@ -68,6 +71,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.IsShipBySeller = p5.IsShipBySeller;
|
||||
result.IsOriginalWarehouse = p5.IsOriginalWarehouse;
|
||||
result.DeliveryCost = p5.DeliveryCost;
|
||||
result.WorkingDays = p5.WorkingDays;
|
||||
result.Id = p5.Id;
|
||||
result.CreatedAt = p5.CreatedAt;
|
||||
return result;
|
||||
|
@ -81,6 +85,7 @@ namespace NetinaShop.Domain.Mappers
|
|||
IsShipBySeller = p7.IsShipBySeller,
|
||||
IsOriginalWarehouse = p7.IsOriginalWarehouse,
|
||||
DeliveryCost = p7.DeliveryCost,
|
||||
WorkingDays = p7.WorkingDays,
|
||||
Id = p7.Id,
|
||||
CreatedAt = p7.CreatedAt
|
||||
};
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using NetinaShop.Domain.Dtos.SmallDtos;
|
||||
using NetinaShop.Domain.Entities.Users;
|
||||
|
||||
namespace NetinaShop.Domain.Mappers
|
||||
{
|
||||
public static partial class UserAddressMapper
|
||||
{
|
||||
public static UserAddress AdaptToUserAddress(this UserAddressSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new UserAddress()
|
||||
{
|
||||
Address = p1.Address,
|
||||
PostalCode = p1.PostalCode,
|
||||
ReceiverFullName = p1.ReceiverFullName,
|
||||
ReceiverPhoneNumber = p1.ReceiverPhoneNumber,
|
||||
LocationLat = p1.LocationLat,
|
||||
LocationLong = p1.LocationLong,
|
||||
Province = p1.Province,
|
||||
City = p1.City,
|
||||
Plaque = p1.Plaque,
|
||||
BuildingUnit = p1.BuildingUnit,
|
||||
UserId = p1.UserId,
|
||||
Id = p1.Id,
|
||||
CreatedAt = p1.CreatedAt
|
||||
};
|
||||
}
|
||||
public static UserAddress AdaptTo(this UserAddressSDto p2, UserAddress p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
UserAddress result = p3 ?? new UserAddress();
|
||||
|
||||
result.Address = p2.Address;
|
||||
result.PostalCode = p2.PostalCode;
|
||||
result.ReceiverFullName = p2.ReceiverFullName;
|
||||
result.ReceiverPhoneNumber = p2.ReceiverPhoneNumber;
|
||||
result.LocationLat = p2.LocationLat;
|
||||
result.LocationLong = p2.LocationLong;
|
||||
result.Province = p2.Province;
|
||||
result.City = p2.City;
|
||||
result.Plaque = p2.Plaque;
|
||||
result.BuildingUnit = p2.BuildingUnit;
|
||||
result.UserId = p2.UserId;
|
||||
result.Id = p2.Id;
|
||||
result.CreatedAt = p2.CreatedAt;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static UserAddressSDto AdaptToSDto(this UserAddress p4)
|
||||
{
|
||||
return p4 == null ? null : new UserAddressSDto()
|
||||
{
|
||||
Address = p4.Address,
|
||||
PostalCode = p4.PostalCode,
|
||||
ReceiverFullName = p4.ReceiverFullName,
|
||||
ReceiverPhoneNumber = p4.ReceiverPhoneNumber,
|
||||
LocationLat = p4.LocationLat,
|
||||
LocationLong = p4.LocationLong,
|
||||
Province = p4.Province,
|
||||
City = p4.City,
|
||||
Plaque = p4.Plaque,
|
||||
BuildingUnit = p4.BuildingUnit,
|
||||
UserId = p4.UserId,
|
||||
Id = p4.Id,
|
||||
CreatedAt = p4.CreatedAt
|
||||
};
|
||||
}
|
||||
public static UserAddressSDto AdaptTo(this UserAddress p5, UserAddressSDto p6)
|
||||
{
|
||||
if (p5 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
UserAddressSDto result = p6 ?? new UserAddressSDto();
|
||||
|
||||
result.Address = p5.Address;
|
||||
result.PostalCode = p5.PostalCode;
|
||||
result.ReceiverFullName = p5.ReceiverFullName;
|
||||
result.ReceiverPhoneNumber = p5.ReceiverPhoneNumber;
|
||||
result.LocationLat = p5.LocationLat;
|
||||
result.LocationLong = p5.LocationLong;
|
||||
result.Province = p5.Province;
|
||||
result.City = p5.City;
|
||||
result.Plaque = p5.Plaque;
|
||||
result.BuildingUnit = p5.BuildingUnit;
|
||||
result.UserId = p5.UserId;
|
||||
result.Id = p5.Id;
|
||||
result.CreatedAt = p5.CreatedAt;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<UserAddress, UserAddressSDto>> ProjectToSDto => p7 => new UserAddressSDto()
|
||||
{
|
||||
Address = p7.Address,
|
||||
PostalCode = p7.PostalCode,
|
||||
ReceiverFullName = p7.ReceiverFullName,
|
||||
ReceiverPhoneNumber = p7.ReceiverPhoneNumber,
|
||||
LocationLat = p7.LocationLat,
|
||||
LocationLong = p7.LocationLong,
|
||||
Province = p7.Province,
|
||||
City = p7.City,
|
||||
Plaque = p7.Plaque,
|
||||
BuildingUnit = p7.BuildingUnit,
|
||||
UserId = p7.UserId,
|
||||
Id = p7.Id,
|
||||
CreatedAt = p7.CreatedAt
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
namespace NetinaShop.Repository.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace NetinaShop.Repository.Extensions;
|
||||
|
||||
public class DbContextOptionCustomExtensionsInfo : DbContextOptionsExtensionInfo
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Extensions;
|
||||
|
||||
public class ModelBuilderQueryFilter
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Accounting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Accounting;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Accounting;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Accounting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Accounting;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Accounting;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Accounting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Accounting;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Accounting;
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
namespace NetinaShop.Repository.Handlers.Addresses;
|
||||
|
||||
public class CreateAddressCommandHandler : IRequestHandler<CreateAddressCommand,bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public CreateAddressCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<bool> Handle(CreateAddressCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.UserId == null)
|
||||
throw new AppException("User id notfound", ApiResultStatusCode.BadRequest);
|
||||
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
||||
throw new AppException("User id wrong", ApiResultStatusCode.BadRequest);
|
||||
|
||||
var ent = UserAddress.Create(request.Address, request.PostalCode, request.ReceiverFullName,
|
||||
request.ReceiverPhoneNumber, request.LocationLat, request.LocationLong, request.Province, request.City,
|
||||
request.Plaque, request.BuildingUnit, userId);
|
||||
|
||||
_repositoryWrapper.SetRepository<UserAddress>().Add(ent);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Addresses;
|
||||
|
||||
public class DeleteAddressCommandHandler : IRequestHandler<DeleteAddressCommand,bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public DeleteAddressCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(DeleteAddressCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var ent = await _repositoryWrapper.SetRepository<UserAddress>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(u => u.Id == request.Id, cancellationToken);
|
||||
if (ent == null)
|
||||
throw new AppException("Address not found", ApiResultStatusCode.NotFound);
|
||||
_repositoryWrapper.SetRepository<UserAddress>()
|
||||
.Delete(ent);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Addresses;
|
||||
|
||||
public class GetUserAddressesQueryHandler : IRequestHandler<GetUserAddressesQuery, List<UserAddressSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetUserAddressesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<UserAddressSDto>> Handle(GetUserAddressesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
Guid userId;
|
||||
if (request.UserId != null)
|
||||
userId = request.UserId.Value;
|
||||
else
|
||||
{
|
||||
if (_currentUserService.UserId == null)
|
||||
throw new AppException("User id notfound", ApiResultStatusCode.BadRequest);
|
||||
if (!Guid.TryParse(_currentUserService.UserId, out userId))
|
||||
throw new AppException("User id wrong", ApiResultStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
return await _repositoryWrapper.SetRepository<UserAddress>()
|
||||
.TableNoTracking
|
||||
.Where(ua => ua.UserId == userId)
|
||||
.Select(UserAddressMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Brands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Brands;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Brands;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Brands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Brands;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Brands;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Brands;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Brands;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Brands;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
|
||||
public class DeleteDiscountCommandHandler : IRequestHandler<DeleteDiscountCommand,bool>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
|
||||
public class GetDiscountQueryHandler : IRequestHandler<GetDiscountQuery, DiscountLDto>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
|
||||
public class GetDiscountsQueryHandler : IRequestHandler<GetDiscountsQuery, List<DiscountSDto>>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Discounts;
|
||||
|
||||
public class UpdateDiscountCommandHandler : IRequestHandler<UpdateDiscountCommand, bool>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Orders;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Orders;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Orders;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Orders;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Orders;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Orders;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public class GetOrderQueryHandler : IRequestHandler<GetOrderQuery, Order>
|
|||
.Where(od => od.OrderId == request.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.Address,od.PostalCode,od.ReceiverPhoneNumber,od.ReceiverFullName,od.DeliveryCost,od.ShippingId,od.OrderId));
|
||||
orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.AddressId,od.DeliveryCost,od.ShippingId,od.OrderId));
|
||||
|
||||
return order;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Orders;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Orders;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.ProductCategories;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.ProductCategories;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using MediatR;
|
||||
using System.Threading;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.ProductCategories;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.ProductCategories;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.ProductCategories;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Products;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Products;
|
||||
|
||||
public class DeleteProductCommandHandler : IRequestHandler<DeleteProductCommand, bool>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Products;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Products;
|
||||
|
||||
public class GetProductQueryHandler : IRequestHandler<GetProductQuery, ProductLDto>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using NetinaShop.Domain.Dtos.LargDtos;
|
||||
using NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Products;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Products;
|
||||
|
||||
public class UpdateProductCommandHandler : IRequestHandler<UpdateProductCommand, bool>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using AppException = NetinaShop.Common.Models.Exception.AppException;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AppException = NetinaShop.Common.Models.Exception.AppException;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
|
||||
public class DeleteReviewCommandHandler : IRequestHandler<DeleteReviewCommand,bool>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
|
||||
public class GetReviewQueryHandler : IRequestHandler<GetReviewQuery,ReviewLDto>
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Reviews;
|
||||
|
||||
public class GetReviewsQueryHandler : IRequestHandler<GetReviewsQuery,List<ReviewSDto>>
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ public class CreateShippingCommandHandler : IRequestHandler<CreateShippingComman
|
|||
public async Task<ShippingSDto> Handle(CreateShippingCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var ent = Shipping.Create(request.Name, request.WarehouseName, request.IsExpressShipping, request.IsShipBySeller,
|
||||
request.IsOriginalWarehouse,request.DeliveryCost);
|
||||
request.IsOriginalWarehouse,request.DeliveryCost,request.WorkingDays);
|
||||
_repositoryWrapper.SetRepository<Shipping>().Add(ent);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return ent.AdaptToSDto();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Warehouses;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Warehouses;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Warehouses;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
|
||||
namespace NetinaShop.Repository.Handlers.Warehouses;
|
||||
|
||||
|
@ -18,7 +19,7 @@ public class UpdateShippingCommandHandler : IRequestHandler<UpdateShippingComman
|
|||
throw new AppException("Shipping not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
var newEnt = Shipping.Create(request.Name, request.WarehouseName, request.IsExpressShipping, request.IsShipBySeller,
|
||||
request.IsOriginalWarehouse,request.DeliveryCost);
|
||||
request.IsOriginalWarehouse,request.DeliveryCost,request.WorkingDays);
|
||||
newEnt.Id = ent.Id;
|
||||
newEnt.CreatedAt = ent.CreatedAt;
|
||||
newEnt.CreatedBy = ent.CreatedBy;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,70 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NetinaShop.Repository.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EditAddress : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "BuildingUnit",
|
||||
schema: "public",
|
||||
table: "UserAddresses",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "City",
|
||||
schema: "public",
|
||||
table: "UserAddresses",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Plaque",
|
||||
schema: "public",
|
||||
table: "UserAddresses",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Province",
|
||||
schema: "public",
|
||||
table: "UserAddresses",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "BuildingUnit",
|
||||
schema: "public",
|
||||
table: "UserAddresses");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "City",
|
||||
schema: "public",
|
||||
table: "UserAddresses");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Plaque",
|
||||
schema: "public",
|
||||
table: "UserAddresses");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Province",
|
||||
schema: "public",
|
||||
table: "UserAddresses");
|
||||
}
|
||||
}
|
||||
}
|
1682
NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.Designer.cs
generated
100644
1682
NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NetinaShop.Repository.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EditShippingAddWorkingDays : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "WorkingDays",
|
||||
schema: "public",
|
||||
table: "Shippings",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "WorkingDays",
|
||||
schema: "public",
|
||||
table: "Shippings");
|
||||
}
|
||||
}
|
||||
}
|
1678
NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.Designer.cs
generated
100644
1678
NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,110 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NetinaShop.Repository.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EditShippingAddAddressId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Address",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PostalCode",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ReceiverFullName",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ReceiverPhoneNumber",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "AddressId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
type: "uuid",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderDeliveries_AddressId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
column: "AddressId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_OrderDeliveries_UserAddresses_AddressId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
column: "AddressId",
|
||||
principalSchema: "public",
|
||||
principalTable: "UserAddresses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_OrderDeliveries_UserAddresses_AddressId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_OrderDeliveries_AddressId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AddressId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Address",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PostalCode",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ReceiverFullName",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ReceiverPhoneNumber",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -534,9 +534,8 @@ namespace NetinaShop.Repository.Migrations
|
|||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
b.Property<Guid>("AddressId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
@ -559,18 +558,6 @@ namespace NetinaShop.Repository.Migrations
|
|||
b.Property<Guid>("OrderId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("PostalCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ReceiverFullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ReceiverPhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("RemovedAt")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
|
@ -582,6 +569,8 @@ namespace NetinaShop.Repository.Migrations
|
|||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ShippingId");
|
||||
|
@ -1115,6 +1104,14 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("BuildingUnit")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("City")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
|
@ -1136,10 +1133,18 @@ namespace NetinaShop.Repository.Migrations
|
|||
b.Property<string>("ModifiedBy")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Plaque")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PostalCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Province")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ReceiverFullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
@ -1253,6 +1258,9 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorkingDays")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shippings", "public");
|
||||
|
@ -1418,6 +1426,11 @@ namespace NetinaShop.Repository.Migrations
|
|||
|
||||
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b =>
|
||||
{
|
||||
b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address")
|
||||
.WithMany()
|
||||
.HasForeignKey("AddressId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
|
||||
.WithMany("OrderDeliveries")
|
||||
.HasForeignKey("OrderId")
|
||||
|
@ -1428,6 +1441,8 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasForeignKey("ShippingId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.Navigation("Address");
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Shipping");
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
namespace NetinaShop.Repository.Models;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Models;
|
||||
|
||||
|
||||
public class ApplicationContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Marten" Version="7.0.0-beta.5" />
|
||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||
<PackageReference Include="FluentValidation" Version="11.9.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||
|
@ -45,11 +46,6 @@
|
|||
<Using Include="MediatR" />
|
||||
<Using Include="Microsoft.AspNetCore.Builder" />
|
||||
<Using Include="Microsoft.AspNetCore.Identity" />
|
||||
<Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
||||
<Using Include="Microsoft.EntityFrameworkCore" />
|
||||
<Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" />
|
||||
<Using Include="Microsoft.EntityFrameworkCore.Infrastructure" />
|
||||
<Using Include="Microsoft.EntityFrameworkCore.Storage" />
|
||||
<Using Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<Using Include="Microsoft.Extensions.Logging" />
|
||||
<Using Include="Microsoft.Extensions.Options" />
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Repositories.Base
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base
|
||||
{
|
||||
public class BaseRepository<T> : Repository<T>, IBaseRepository<T> where T : class, IApiEntity
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Repositories.Base.Contracts
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base.Contracts
|
||||
{
|
||||
public interface IReadRepository<T> where T : class, IApiEntity
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Repositories.Base.Contracts
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base.Contracts
|
||||
{
|
||||
internal interface IRepository<T> where T : class, IApiEntity
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Repositories.Base
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base
|
||||
{
|
||||
public class ReadRepository<T> : Repository<T>, IDisposable, IReadRepository<T> where T : class, IApiEntity
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Repositories.Base
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base
|
||||
{
|
||||
public class Repository<T> : IRepository<T> where T : class, IApiEntity
|
||||
{
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
namespace NetinaShop.Repository.Repositories.Base;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base;
|
||||
public class RepositoryWrapper : IRepositoryWrapper
|
||||
{
|
||||
private readonly ApplicationContext _context;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Base
|
||||
{
|
||||
public class WriteRepository<T> : Repository<T>, IDisposable, IWriteRepository<T> where T : class, IApiEntity
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
namespace NetinaShop.Repository.Repositories.Entity.Abstracts;
|
||||
|
||||
public interface IDiscountRepository : IScopedDependency, IDisposable, IReadRepository<Discount>, IWriteRepository<Discount>
|
||||
{
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System.Linq.Expressions;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Entity.Abstracts;
|
||||
|
||||
public interface IMartenRepository : IScopedDependency
|
||||
{
|
||||
Task<List<TSetting>> GetEntitiesAsync<TSetting>(CancellationToken cancellation) where TSetting : notnull;
|
||||
Task<List<TSetting>> GetEntitiesAsync<TSetting>(Expression<Func<TSetting,bool>> expression,CancellationToken cancellation) where TSetting : notnull;
|
||||
|
||||
Task<TSetting> GetEntityAsync<TSetting>(Guid id,CancellationToken cancellation) where TSetting : notnull;
|
||||
Task<TSetting> GetEntityAsync<TSetting>(Expression<Func<TSetting, bool>> expression, CancellationToken cancellation) where TSetting : notnull;
|
||||
|
||||
Task AddOrUpdateEntityAsync<TSetting>(TSetting setting, CancellationToken cancellation) where TSetting : notnull;
|
||||
Task RemoveEntityAsync<TSetting>(CancellationToken cancellation);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
namespace NetinaShop.Repository.Repositories.Entity.Abstracts;
|
||||
|
||||
public interface IProductRepository : IScopedDependency , IDisposable, IReadRepository<Product>, IWriteRepository<Product>
|
||||
{
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
namespace NetinaShop.Repository.Repositories.Entity;
|
||||
|
||||
public class DiscountRepository : BaseRepository<Discount>, IDiscountRepository
|
||||
{
|
||||
|
||||
public DiscountRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using System.Linq.Expressions;
|
||||
using Marten;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.Entity;
|
||||
|
||||
public class MartenRepository : IMartenRepository
|
||||
{
|
||||
private readonly IDocumentStore _documentStore;
|
||||
|
||||
public MartenRepository(IDocumentStore documentStore)
|
||||
{
|
||||
_documentStore = documentStore;
|
||||
}
|
||||
public async Task<List<TSetting>> GetEntitiesAsync<TSetting>(CancellationToken cancellation) where TSetting : notnull
|
||||
{
|
||||
await using var session = _documentStore.QuerySession();
|
||||
var entities = await session.Query<TSetting>().ToListAsync(cancellation);
|
||||
return entities.ToList();
|
||||
}
|
||||
|
||||
public async Task<List<TSetting>> GetEntitiesAsync<TSetting>(Expression<Func<TSetting, bool>> expression, CancellationToken cancellation) where TSetting : notnull
|
||||
{
|
||||
await using var session = _documentStore.QuerySession();
|
||||
var entities = await session.Query<TSetting>().Where(expression).ToListAsync(cancellation);
|
||||
return entities.ToList();
|
||||
}
|
||||
|
||||
public async Task<TSetting> GetEntityAsync<TSetting>(Guid id,CancellationToken cancellation) where TSetting : notnull
|
||||
{
|
||||
await using var session = _documentStore.QuerySession();
|
||||
var setting = await session.LoadAsync<TSetting>(id,cancellation);
|
||||
if (setting == null)
|
||||
throw new AppException($"{nameof(setting)} not found", ApiResultStatusCode.NotFound);
|
||||
return setting;
|
||||
}
|
||||
|
||||
public async Task<TSetting> GetEntityAsync<TSetting>(Expression<Func<TSetting, bool>> expression, CancellationToken cancellation) where TSetting : notnull
|
||||
{
|
||||
await using var session = _documentStore.QuerySession();
|
||||
var entity = await session.Query<TSetting>().FirstOrDefaultAsync(expression,cancellation);
|
||||
if (entity == null)
|
||||
throw new AppException($"{nameof(entity)} not found", ApiResultStatusCode.NotFound);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task AddOrUpdateEntityAsync<TSetting>(TSetting setting, CancellationToken cancellation) where TSetting : notnull
|
||||
{
|
||||
if (setting == null)
|
||||
throw new AppException($"{nameof(setting)} is null", ApiResultStatusCode.BadRequest);
|
||||
|
||||
await using var session = _documentStore.LightweightSession();
|
||||
session.Store(setting);
|
||||
await session.SaveChangesAsync(cancellation);
|
||||
}
|
||||
|
||||
public Task RemoveEntityAsync<TSetting>(CancellationToken cancellation)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
namespace NetinaShop.Repository.Repositories.Entity;
|
||||
|
||||
public class ProductRepository : BaseRepository<Product>, IProductRepository
|
||||
{
|
||||
|
||||
public ProductRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
namespace NetinaShop.Repository.Repositories.UnitOfWork;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
|
||||
namespace NetinaShop.Repository.Repositories.UnitOfWork;
|
||||
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Repository.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace NetinaShop.Repository.Services;
|
||||
|
||||
|
||||
public class DbInitializerService : IDbInitializerService
|
||||
|
|
Loading…
Reference in New Issue