Compare commits
2 Commits
879b59f0bd
...
4100e2f8fa
Author | SHA1 | Date |
---|---|---|
|
4100e2f8fa | |
|
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();
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public static class LoggerConfig
|
|||
o.MinimumEventLevel = LogEventLevel.Error;
|
||||
o.Dsn = "https://592b7fbb29464442a8e996247abe857f@watcher.igarson.app/7";
|
||||
})
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
|
||||
.CreateLogger();
|
||||
}
|
||||
}
|
|
@ -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,90 @@
|
|||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using NetinaShop.Domain;
|
||||
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 entityType = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(page.Type);
|
||||
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 = 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 type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(page.Type);
|
||||
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 = 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,
|
||||
};
|
||||
var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(entity.Type);
|
||||
basePage.Data = JsonConvert.SerializeObject(((JsonElement)entity.Data).Deserialize(type));
|
||||
await _martenRepository.AddOrUpdateEntityAsync(basePage, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
||||
|
||||
if (discount == null)
|
||||
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
||||
throw new AppException("تخفیف وجود منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
|
||||
|
||||
double discountPrice = 0;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -21,12 +21,12 @@ public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountComman
|
|||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
||||
if (discount == null || discount.IsExpired())
|
||||
throw new AppException("Discount is expired or not found", ApiResultStatusCode.NotFound);
|
||||
throw new AppException("تخفیف منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
using NetinaShop.Domain.Entities.Orders;
|
||||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
|
||||
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,26 +13,35 @@ 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 order = await _repositoryWrapper.SetRepository<Order>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken);
|
||||
|
||||
if (order == null)
|
||||
throw new AppException("Order not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
var orderDelivery = await _repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(od => od.OrderId == request.OrderId, cancellationToken);
|
||||
if (orderDelivery != null)
|
||||
{
|
||||
order.AddOrderDelivery(orderDelivery.AddressId, orderDelivery.DeliveryCost, orderDelivery.ShippingId, orderDelivery.OrderId, orderDelivery.Id);
|
||||
}
|
||||
|
||||
var shipping = await _repositoryWrapper.SetRepository<Shipping>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.Id == request.ShippingId, cancellationToken);
|
||||
if (shipping == null)
|
||||
throw new AppException("Shipping not found", ApiResultStatusCode.NotFound);
|
||||
foreach (var orderDelivery in order.OrderDeliveries)
|
||||
{
|
||||
_repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.Delete(orderDelivery);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
order.OrderDeliveries.Clear();
|
||||
order.AddOrderDelivery(request.Address,request.PostalCode,request.ReceiverPhoneNumber,request.ReceiverFullName,shipping.DeliveryCost,request.ShippingId,request.OrderId);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
// ? (totalProductPrice / 100) * _shopSettings.ServiceFee
|
||||
// : _shopSettings.ServiceFee;
|
||||
var servicePrice = 0;
|
||||
var deliveryPrice = order.OrderDeliveries.Sum(op => op.DeliveryCost);
|
||||
var deliveryPrice = order.OrderDelivery?.DeliveryCost ?? 0;
|
||||
double discountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
|
||||
if (!order.DiscountCode.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -35,7 +35,8 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
var taxesPrice = 0;
|
||||
|
||||
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice);
|
||||
|
||||
order.OrderProducts.Clear();
|
||||
order.OrderDelivery = null;
|
||||
_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>>;
|
|
@ -22,18 +22,9 @@ public class OrderLDto : BaseDto<OrderLDto,Order>
|
|||
|
||||
public List<OrderProductSDto> OrderProducts { get; set; } = new();
|
||||
|
||||
public List<OrderDeliverySDto> OrderDeliveries { get; set; } = new();
|
||||
|
||||
public List<PaymentSDto> Payments { get; set; } = new();
|
||||
|
||||
public OrderDeliverySDto OrderDelivery
|
||||
{
|
||||
get
|
||||
{
|
||||
if (OrderDeliveries.Count > 0)
|
||||
return OrderDeliveries.FirstOrDefault() ?? new OrderDeliverySDto();
|
||||
return new OrderDeliverySDto();
|
||||
}
|
||||
}
|
||||
|
||||
public OrderDeliverySDto? OrderDelivery { get; internal set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -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,17 @@
|
|||
using NetinaShop.Domain.Entities.Pages;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
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 string Data { get; set; } = string.Empty;
|
||||
|
||||
public T GetData<T>() => JsonConvert.DeserializeObject<T>(Data);
|
||||
}
|
|
@ -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,12 +72,20 @@ 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);
|
||||
OrderDeliveries.Add(orderDelivery);
|
||||
var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId);
|
||||
if (OrderDelivery != null)
|
||||
orderDelivery.Id = OrderDelivery.Id;
|
||||
OrderDelivery = orderDelivery;
|
||||
}
|
||||
|
||||
public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId,Guid orderDeliveryId)
|
||||
{
|
||||
var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId);
|
||||
orderDelivery.Id = orderDeliveryId;
|
||||
OrderDelivery = orderDelivery;
|
||||
}
|
||||
public void SetTotalPrice(double totalProductPrice,
|
||||
double packingPrice,
|
||||
double servicePrice,
|
||||
|
@ -122,8 +130,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);
|
||||
}
|
||||
}
|
|
@ -69,9 +69,10 @@ public partial class Order : ApiEntity
|
|||
public Guid UserId { get; internal set; }
|
||||
public ApplicationUser? User { get; internal set; }
|
||||
|
||||
public OrderDelivery? OrderDelivery { get; set; }
|
||||
|
||||
public List<OrderProduct> OrderProducts { get; internal set; } = new();
|
||||
|
||||
public List<OrderDelivery> OrderDeliveries { get; internal set; } = new();
|
||||
|
||||
public List<Payment> Payments { get; internal set; } = new();
|
||||
}
|
|
@ -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,16 @@
|
|||
using System.Text.Json;
|
||||
|
||||
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,
|
||||
}
|
|
@ -34,225 +34,233 @@ namespace NetinaShop.Domain.Mappers
|
|||
PreparingMinute = p1.PreparingMinute,
|
||||
DiscountCode = p1.DiscountCode,
|
||||
User = new ApplicationUser() {PhoneNumber = p1.UserPhoneNumber},
|
||||
OrderDelivery = p1.OrderDelivery == null ? null : new OrderDelivery()
|
||||
{
|
||||
AddressId = p1.OrderDelivery.AddressId,
|
||||
Address = p1.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p1.OrderDelivery.Address, typeof(UserAddress)),
|
||||
DeliveryCost = p1.OrderDelivery.DeliveryCost,
|
||||
ShippingId = p1.OrderDelivery.ShippingId,
|
||||
Shipping = new Shipping() {Id = p1.OrderDelivery.ShippingId},
|
||||
OrderId = p1.OrderDelivery.OrderId,
|
||||
Order = new Order() {Id = p1.OrderDelivery.OrderId},
|
||||
Id = p1.OrderDelivery.Id,
|
||||
CreatedAt = p1.OrderDelivery.CreatedAt
|
||||
},
|
||||
OrderProducts = funcMain1(p1.OrderProducts),
|
||||
OrderDeliveries = funcMain2(p1.OrderDeliveries),
|
||||
Payments = funcMain3(p1.Payments),
|
||||
Payments = funcMain2(p1.Payments),
|
||||
Id = p1.Id,
|
||||
CreatedAt = p1.CreatedAt
|
||||
};
|
||||
}
|
||||
public static Order AdaptTo(this OrderLDto p5, Order p6)
|
||||
public static Order AdaptTo(this OrderLDto p4, Order p5)
|
||||
{
|
||||
if (p5 == null)
|
||||
if (p4 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Order result = p6 ?? new Order();
|
||||
Order result = p5 ?? new Order();
|
||||
|
||||
result.FactorCode = p5.FactorCode;
|
||||
result.TotalProductsPrice = (double)p5.TotalProductsPrice;
|
||||
result.PackingPrice = (double)p5.PackingPrice;
|
||||
result.ServicePrice = (double)p5.ServicePrice;
|
||||
result.DeliveryPrice = (double)p5.DeliveryPrice;
|
||||
result.DiscountPrice = (double)p5.DiscountPrice;
|
||||
result.TaxesPrice = (double)p5.TaxesPrice;
|
||||
result.TotalPrice = (double)p5.TotalPrice;
|
||||
result.IsPayed = p5.IsPayed;
|
||||
result.OrderStatus = p5.OrderStatus;
|
||||
result.DoneAt = p5.DoneAt;
|
||||
result.OrderAt = p5.OrderAt;
|
||||
result.PreparingMinute = p5.PreparingMinute;
|
||||
result.DiscountCode = p5.DiscountCode;
|
||||
result.User = funcMain4(new Never(), result.User, p5);
|
||||
result.OrderProducts = funcMain5(p5.OrderProducts, result.OrderProducts);
|
||||
result.OrderDeliveries = funcMain6(p5.OrderDeliveries, result.OrderDeliveries);
|
||||
result.Payments = funcMain7(p5.Payments, result.Payments);
|
||||
result.Id = p5.Id;
|
||||
result.CreatedAt = p5.CreatedAt;
|
||||
result.FactorCode = p4.FactorCode;
|
||||
result.TotalProductsPrice = (double)p4.TotalProductsPrice;
|
||||
result.PackingPrice = (double)p4.PackingPrice;
|
||||
result.ServicePrice = (double)p4.ServicePrice;
|
||||
result.DeliveryPrice = (double)p4.DeliveryPrice;
|
||||
result.DiscountPrice = (double)p4.DiscountPrice;
|
||||
result.TaxesPrice = (double)p4.TaxesPrice;
|
||||
result.TotalPrice = (double)p4.TotalPrice;
|
||||
result.IsPayed = p4.IsPayed;
|
||||
result.OrderStatus = p4.OrderStatus;
|
||||
result.DoneAt = p4.DoneAt;
|
||||
result.OrderAt = p4.OrderAt;
|
||||
result.PreparingMinute = p4.PreparingMinute;
|
||||
result.DiscountCode = p4.DiscountCode;
|
||||
result.User = funcMain3(new Never(), result.User, p4);
|
||||
result.OrderDelivery = funcMain4(p4.OrderDelivery, result.OrderDelivery);
|
||||
result.OrderProducts = funcMain7(p4.OrderProducts, result.OrderProducts);
|
||||
result.Payments = funcMain8(p4.Payments, result.Payments);
|
||||
result.Id = p4.Id;
|
||||
result.CreatedAt = p4.CreatedAt;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<OrderLDto, Order>> ProjectToOrder => p15 => new Order()
|
||||
public static Expression<Func<OrderLDto, Order>> ProjectToOrder => p18 => new Order()
|
||||
{
|
||||
FactorCode = p15.FactorCode,
|
||||
TotalProductsPrice = (double)p15.TotalProductsPrice,
|
||||
PackingPrice = (double)p15.PackingPrice,
|
||||
ServicePrice = (double)p15.ServicePrice,
|
||||
DeliveryPrice = (double)p15.DeliveryPrice,
|
||||
DiscountPrice = (double)p15.DiscountPrice,
|
||||
TaxesPrice = (double)p15.TaxesPrice,
|
||||
TotalPrice = (double)p15.TotalPrice,
|
||||
IsPayed = p15.IsPayed,
|
||||
OrderStatus = p15.OrderStatus,
|
||||
DoneAt = p15.DoneAt,
|
||||
OrderAt = p15.OrderAt,
|
||||
PreparingMinute = p15.PreparingMinute,
|
||||
DiscountCode = p15.DiscountCode,
|
||||
User = new ApplicationUser() {PhoneNumber = p15.UserPhoneNumber},
|
||||
OrderProducts = p15.OrderProducts.Select<OrderProductSDto, OrderProduct>(p16 => new OrderProduct()
|
||||
FactorCode = p18.FactorCode,
|
||||
TotalProductsPrice = (double)p18.TotalProductsPrice,
|
||||
PackingPrice = (double)p18.PackingPrice,
|
||||
ServicePrice = (double)p18.ServicePrice,
|
||||
DeliveryPrice = (double)p18.DeliveryPrice,
|
||||
DiscountPrice = (double)p18.DiscountPrice,
|
||||
TaxesPrice = (double)p18.TaxesPrice,
|
||||
TotalPrice = (double)p18.TotalPrice,
|
||||
IsPayed = p18.IsPayed,
|
||||
OrderStatus = p18.OrderStatus,
|
||||
DoneAt = p18.DoneAt,
|
||||
OrderAt = p18.OrderAt,
|
||||
PreparingMinute = p18.PreparingMinute,
|
||||
DiscountCode = p18.DiscountCode,
|
||||
User = new ApplicationUser() {PhoneNumber = p18.UserPhoneNumber},
|
||||
OrderDelivery = p18.OrderDelivery == null ? null : new OrderDelivery()
|
||||
{
|
||||
Count = p16.Count,
|
||||
ProductFee = p16.ProductFee,
|
||||
ProductFeeWithDiscount = p16.ProductFeeWithDiscount,
|
||||
HasDiscount = p16.HasDiscount,
|
||||
ProductCost = p16.ProductCost,
|
||||
PackingFee = p16.PackingFee,
|
||||
PackingCost = p16.PackingCost,
|
||||
OrderProductStatus = p16.OrderProductStatus,
|
||||
ProductId = p16.ProductId,
|
||||
AddressId = p18.OrderDelivery.AddressId,
|
||||
Address = p18.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p18.OrderDelivery.Address, typeof(UserAddress)),
|
||||
DeliveryCost = p18.OrderDelivery.DeliveryCost,
|
||||
ShippingId = p18.OrderDelivery.ShippingId,
|
||||
Shipping = new Shipping() {Id = p18.OrderDelivery.ShippingId},
|
||||
OrderId = p18.OrderDelivery.OrderId,
|
||||
Order = new Order() {Id = p18.OrderDelivery.OrderId},
|
||||
Id = p18.OrderDelivery.Id,
|
||||
CreatedAt = p18.OrderDelivery.CreatedAt
|
||||
},
|
||||
OrderProducts = p18.OrderProducts.Select<OrderProductSDto, OrderProduct>(p19 => new OrderProduct()
|
||||
{
|
||||
Count = p19.Count,
|
||||
ProductFee = p19.ProductFee,
|
||||
ProductFeeWithDiscount = p19.ProductFeeWithDiscount,
|
||||
HasDiscount = p19.HasDiscount,
|
||||
ProductCost = p19.ProductCost,
|
||||
PackingFee = p19.PackingFee,
|
||||
PackingCost = p19.PackingCost,
|
||||
OrderProductStatus = p19.OrderProductStatus,
|
||||
ProductId = p19.ProductId,
|
||||
Product = new Product()
|
||||
{
|
||||
Cost = p16.ProductCost,
|
||||
Id = p16.ProductId
|
||||
Cost = p19.ProductCost,
|
||||
Id = p19.ProductId
|
||||
},
|
||||
OrderId = p16.OrderId,
|
||||
Order = new Order() {Id = p16.OrderId},
|
||||
Id = p16.Id,
|
||||
CreatedAt = p16.CreatedAt
|
||||
}).ToList<OrderProduct>(),
|
||||
OrderDeliveries = p15.OrderDeliveries.Select<OrderDeliverySDto, OrderDelivery>(p17 => new OrderDelivery()
|
||||
{
|
||||
Address = p17.Address,
|
||||
PostalCode = p17.PostalCode,
|
||||
ReceiverPhoneNumber = p17.ReceiverPhoneNumber,
|
||||
ReceiverFullName = p17.ReceiverFullName,
|
||||
ShippingId = p17.ShippingId,
|
||||
Shipping = new Shipping() {Id = p17.ShippingId},
|
||||
OrderId = p17.OrderId,
|
||||
Order = new Order() {Id = p17.OrderId},
|
||||
Id = p17.Id,
|
||||
CreatedAt = p17.CreatedAt
|
||||
}).ToList<OrderDelivery>(),
|
||||
Payments = p15.Payments.Select<PaymentSDto, Payment>(p18 => new Payment()
|
||||
{
|
||||
FactorNumber = p18.FactorNumber,
|
||||
Amount = p18.Amount,
|
||||
Description = p18.Description,
|
||||
TransactionCode = p18.TransactionCode,
|
||||
CardPan = p18.CardPan,
|
||||
Authority = p18.Authority,
|
||||
Type = p18.Type,
|
||||
Status = p18.Status,
|
||||
OrderId = p18.OrderId,
|
||||
Order = new Order() {Id = p18.OrderId},
|
||||
UserId = p18.UserId,
|
||||
User = new ApplicationUser()
|
||||
{
|
||||
Id = p18.UserId,
|
||||
PhoneNumber = p18.UserPhoneNumber
|
||||
},
|
||||
Id = p18.Id,
|
||||
CreatedAt = p18.CreatedAt
|
||||
}).ToList<Payment>(),
|
||||
Id = p15.Id,
|
||||
CreatedAt = p15.CreatedAt
|
||||
};
|
||||
public static OrderLDto AdaptToLDto(this Order p19)
|
||||
{
|
||||
return p19 == null ? null : new OrderLDto()
|
||||
{
|
||||
FactorCode = p19.FactorCode,
|
||||
TotalPrice = (long)p19.TotalPrice,
|
||||
DeliveryPrice = (long)p19.DeliveryPrice,
|
||||
TaxesPrice = (long)p19.TaxesPrice,
|
||||
ServicePrice = (long)p19.ServicePrice,
|
||||
PackingPrice = (long)p19.PackingPrice,
|
||||
TotalProductsPrice = (long)p19.TotalProductsPrice,
|
||||
DiscountPrice = (long)p19.DiscountPrice,
|
||||
IsPayed = p19.IsPayed,
|
||||
OrderStatus = p19.OrderStatus,
|
||||
DoneAt = p19.DoneAt,
|
||||
OrderAt = p19.OrderAt,
|
||||
PreparingMinute = p19.PreparingMinute,
|
||||
DiscountCode = p19.DiscountCode,
|
||||
UserFullName = p19.User != null ? p19.User.FirstName + " " + p19.User.LastName : string.Empty,
|
||||
UserPhoneNumber = p19.User != null ? p19.User.PhoneNumber : string.Empty,
|
||||
OrderProducts = funcMain8(p19.OrderProducts),
|
||||
OrderDeliveries = funcMain9(p19.OrderDeliveries),
|
||||
Payments = funcMain10(p19.Payments),
|
||||
OrderId = p19.OrderId,
|
||||
Order = new Order() {Id = p19.OrderId},
|
||||
Id = p19.Id,
|
||||
CreatedAt = p19.CreatedAt
|
||||
}).ToList<OrderProduct>(),
|
||||
Payments = p18.Payments.Select<PaymentSDto, Payment>(p20 => new Payment()
|
||||
{
|
||||
FactorNumber = p20.FactorNumber,
|
||||
Amount = p20.Amount,
|
||||
Description = p20.Description,
|
||||
TransactionCode = p20.TransactionCode,
|
||||
CardPan = p20.CardPan,
|
||||
Authority = p20.Authority,
|
||||
Type = p20.Type,
|
||||
Status = p20.Status,
|
||||
OrderId = p20.OrderId,
|
||||
Order = new Order() {Id = p20.OrderId},
|
||||
UserId = p20.UserId,
|
||||
User = new ApplicationUser()
|
||||
{
|
||||
Id = p20.UserId,
|
||||
PhoneNumber = p20.UserPhoneNumber
|
||||
},
|
||||
Id = p20.Id,
|
||||
CreatedAt = p20.CreatedAt
|
||||
}).ToList<Payment>(),
|
||||
Id = p18.Id,
|
||||
CreatedAt = p18.CreatedAt
|
||||
};
|
||||
public static OrderLDto AdaptToLDto(this Order p21)
|
||||
{
|
||||
return p21 == null ? null : new OrderLDto()
|
||||
{
|
||||
FactorCode = p21.FactorCode,
|
||||
TotalPrice = (long)p21.TotalPrice,
|
||||
DeliveryPrice = (long)p21.DeliveryPrice,
|
||||
TaxesPrice = (long)p21.TaxesPrice,
|
||||
ServicePrice = (long)p21.ServicePrice,
|
||||
PackingPrice = (long)p21.PackingPrice,
|
||||
TotalProductsPrice = (long)p21.TotalProductsPrice,
|
||||
DiscountPrice = (long)p21.DiscountPrice,
|
||||
IsPayed = p21.IsPayed,
|
||||
OrderStatus = p21.OrderStatus,
|
||||
DoneAt = p21.DoneAt,
|
||||
OrderAt = p21.OrderAt,
|
||||
PreparingMinute = p21.PreparingMinute,
|
||||
DiscountCode = p21.DiscountCode,
|
||||
UserFullName = p21.User != null ? p21.User.FirstName + " " + p21.User.LastName : string.Empty,
|
||||
UserPhoneNumber = p21.User != null ? p21.User.PhoneNumber : string.Empty,
|
||||
OrderProducts = funcMain9(p21.OrderProducts),
|
||||
Payments = funcMain10(p21.Payments),
|
||||
OrderDelivery = p21.OrderDelivery == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
Address = p21.OrderDelivery.Address == null ? null : p21.OrderDelivery.Address.ToString(),
|
||||
ShippingMethod = p21.OrderDelivery.Shipping != null ? p21.OrderDelivery.Shipping.Name : string.Empty,
|
||||
DeliveryCost = p21.OrderDelivery.DeliveryCost,
|
||||
AddressId = p21.OrderDelivery.AddressId,
|
||||
OrderId = p21.OrderDelivery.OrderId,
|
||||
ShippingId = p21.OrderDelivery.ShippingId,
|
||||
Id = p21.OrderDelivery.Id,
|
||||
CreatedAt = p21.OrderDelivery.CreatedAt
|
||||
},
|
||||
Id = p21.Id,
|
||||
CreatedAt = p21.CreatedAt
|
||||
};
|
||||
}
|
||||
public static OrderLDto AdaptTo(this Order p23, OrderLDto p24)
|
||||
public static OrderLDto AdaptTo(this Order p24, OrderLDto p25)
|
||||
{
|
||||
if (p23 == null)
|
||||
if (p24 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
OrderLDto result = p24 ?? new OrderLDto();
|
||||
OrderLDto result = p25 ?? new OrderLDto();
|
||||
|
||||
result.FactorCode = p23.FactorCode;
|
||||
result.TotalPrice = (long)p23.TotalPrice;
|
||||
result.DeliveryPrice = (long)p23.DeliveryPrice;
|
||||
result.TaxesPrice = (long)p23.TaxesPrice;
|
||||
result.ServicePrice = (long)p23.ServicePrice;
|
||||
result.PackingPrice = (long)p23.PackingPrice;
|
||||
result.TotalProductsPrice = (long)p23.TotalProductsPrice;
|
||||
result.DiscountPrice = (long)p23.DiscountPrice;
|
||||
result.IsPayed = p23.IsPayed;
|
||||
result.OrderStatus = p23.OrderStatus;
|
||||
result.DoneAt = p23.DoneAt;
|
||||
result.OrderAt = p23.OrderAt;
|
||||
result.PreparingMinute = p23.PreparingMinute;
|
||||
result.DiscountCode = p23.DiscountCode;
|
||||
result.UserFullName = p23.User != null ? p23.User.FirstName + " " + p23.User.LastName : string.Empty;
|
||||
result.UserPhoneNumber = p23.User != null ? p23.User.PhoneNumber : string.Empty;
|
||||
result.OrderProducts = funcMain11(p23.OrderProducts, result.OrderProducts);
|
||||
result.OrderDeliveries = funcMain12(p23.OrderDeliveries, result.OrderDeliveries);
|
||||
result.Payments = funcMain13(p23.Payments, result.Payments);
|
||||
result.Id = p23.Id;
|
||||
result.CreatedAt = p23.CreatedAt;
|
||||
result.FactorCode = p24.FactorCode;
|
||||
result.TotalPrice = (long)p24.TotalPrice;
|
||||
result.DeliveryPrice = (long)p24.DeliveryPrice;
|
||||
result.TaxesPrice = (long)p24.TaxesPrice;
|
||||
result.ServicePrice = (long)p24.ServicePrice;
|
||||
result.PackingPrice = (long)p24.PackingPrice;
|
||||
result.TotalProductsPrice = (long)p24.TotalProductsPrice;
|
||||
result.DiscountPrice = (long)p24.DiscountPrice;
|
||||
result.IsPayed = p24.IsPayed;
|
||||
result.OrderStatus = p24.OrderStatus;
|
||||
result.DoneAt = p24.DoneAt;
|
||||
result.OrderAt = p24.OrderAt;
|
||||
result.PreparingMinute = p24.PreparingMinute;
|
||||
result.DiscountCode = p24.DiscountCode;
|
||||
result.UserFullName = p24.User != null ? p24.User.FirstName + " " + p24.User.LastName : string.Empty;
|
||||
result.UserPhoneNumber = p24.User != null ? p24.User.PhoneNumber : string.Empty;
|
||||
result.OrderProducts = funcMain11(p24.OrderProducts, result.OrderProducts);
|
||||
result.Payments = funcMain12(p24.Payments, result.Payments);
|
||||
result.OrderDelivery = funcMain13(p24.OrderDelivery, result.OrderDelivery);
|
||||
result.Id = p24.Id;
|
||||
result.CreatedAt = p24.CreatedAt;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Order, OrderLDto>> ProjectToLDto => p31 => new OrderLDto()
|
||||
public static Expression<Func<Order, OrderLDto>> ProjectToLDto => p32 => new OrderLDto()
|
||||
{
|
||||
FactorCode = p31.FactorCode,
|
||||
TotalPrice = (long)p31.TotalPrice,
|
||||
DeliveryPrice = (long)p31.DeliveryPrice,
|
||||
TaxesPrice = (long)p31.TaxesPrice,
|
||||
ServicePrice = (long)p31.ServicePrice,
|
||||
PackingPrice = (long)p31.PackingPrice,
|
||||
TotalProductsPrice = (long)p31.TotalProductsPrice,
|
||||
DiscountPrice = (long)p31.DiscountPrice,
|
||||
IsPayed = p31.IsPayed,
|
||||
OrderStatus = p31.OrderStatus,
|
||||
DoneAt = p31.DoneAt,
|
||||
OrderAt = p31.OrderAt,
|
||||
PreparingMinute = p31.PreparingMinute,
|
||||
DiscountCode = p31.DiscountCode,
|
||||
UserFullName = p31.User != null ? p31.User.FirstName + " " + p31.User.LastName : string.Empty,
|
||||
UserPhoneNumber = p31.User != null ? p31.User.PhoneNumber : string.Empty,
|
||||
OrderProducts = p31.OrderProducts.Select<OrderProduct, OrderProductSDto>(p32 => new OrderProductSDto()
|
||||
FactorCode = p32.FactorCode,
|
||||
TotalPrice = (long)p32.TotalPrice,
|
||||
DeliveryPrice = (long)p32.DeliveryPrice,
|
||||
TaxesPrice = (long)p32.TaxesPrice,
|
||||
ServicePrice = (long)p32.ServicePrice,
|
||||
PackingPrice = (long)p32.PackingPrice,
|
||||
TotalProductsPrice = (long)p32.TotalProductsPrice,
|
||||
DiscountPrice = (long)p32.DiscountPrice,
|
||||
IsPayed = p32.IsPayed,
|
||||
OrderStatus = p32.OrderStatus,
|
||||
DoneAt = p32.DoneAt,
|
||||
OrderAt = p32.OrderAt,
|
||||
PreparingMinute = p32.PreparingMinute,
|
||||
DiscountCode = p32.DiscountCode,
|
||||
UserFullName = p32.User != null ? p32.User.FirstName + " " + p32.User.LastName : string.Empty,
|
||||
UserPhoneNumber = p32.User != null ? p32.User.PhoneNumber : string.Empty,
|
||||
OrderProducts = p32.OrderProducts.Select<OrderProduct, OrderProductSDto>(p33 => new OrderProductSDto()
|
||||
{
|
||||
Count = p32.Count,
|
||||
ProductFee = p32.ProductFee,
|
||||
ProductFeeWithDiscount = p32.ProductFeeWithDiscount,
|
||||
HasDiscount = p32.HasDiscount,
|
||||
ProductCost = p32.ProductCost,
|
||||
PackingFee = p32.PackingFee,
|
||||
PackingCost = p32.PackingCost,
|
||||
OrderProductStatus = p32.OrderProductStatus,
|
||||
ProductId = p32.ProductId,
|
||||
ProductName = p32.Product != null ? p32.Product.PersianName : string.Empty,
|
||||
OrderId = p32.OrderId,
|
||||
Id = p32.Id,
|
||||
CreatedAt = p32.CreatedAt
|
||||
}).ToList<OrderProductSDto>(),
|
||||
OrderDeliveries = p31.OrderDeliveries.Select<OrderDelivery, OrderDeliverySDto>(p33 => new OrderDeliverySDto()
|
||||
{
|
||||
Address = p33.Address,
|
||||
PostalCode = p33.PostalCode,
|
||||
ReceiverPhoneNumber = p33.ReceiverPhoneNumber,
|
||||
ReceiverFullName = p33.ReceiverFullName,
|
||||
ShippingMethod = p33.Shipping != null ? p33.Shipping.Name : string.Empty,
|
||||
Count = p33.Count,
|
||||
ProductFee = p33.ProductFee,
|
||||
ProductFeeWithDiscount = p33.ProductFeeWithDiscount,
|
||||
HasDiscount = p33.HasDiscount,
|
||||
ProductCost = p33.ProductCost,
|
||||
PackingFee = p33.PackingFee,
|
||||
PackingCost = p33.PackingCost,
|
||||
OrderProductStatus = p33.OrderProductStatus,
|
||||
ProductId = p33.ProductId,
|
||||
ProductName = p33.Product != null ? p33.Product.PersianName : string.Empty,
|
||||
OrderId = p33.OrderId,
|
||||
ShippingId = p33.ShippingId,
|
||||
Id = p33.Id,
|
||||
CreatedAt = p33.CreatedAt
|
||||
}).ToList<OrderDeliverySDto>(),
|
||||
Payments = p31.Payments.Select<Payment, PaymentSDto>(p34 => new PaymentSDto()
|
||||
}).ToList<OrderProductSDto>(),
|
||||
Payments = p32.Payments.Select<Payment, PaymentSDto>(p34 => new PaymentSDto()
|
||||
{
|
||||
FactorNumber = p34.FactorNumber,
|
||||
Amount = p34.Amount,
|
||||
|
@ -269,8 +277,19 @@ namespace NetinaShop.Domain.Mappers
|
|||
Id = p34.Id,
|
||||
CreatedAt = p34.CreatedAt
|
||||
}).ToList<PaymentSDto>(),
|
||||
Id = p31.Id,
|
||||
CreatedAt = p31.CreatedAt
|
||||
OrderDelivery = p32.OrderDelivery == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
Address = p32.OrderDelivery.Address == null ? null : p32.OrderDelivery.Address.ToString(),
|
||||
ShippingMethod = p32.OrderDelivery.Shipping != null ? p32.OrderDelivery.Shipping.Name : string.Empty,
|
||||
DeliveryCost = p32.OrderDelivery.DeliveryCost,
|
||||
AddressId = p32.OrderDelivery.AddressId,
|
||||
OrderId = p32.OrderDelivery.OrderId,
|
||||
ShippingId = p32.OrderDelivery.ShippingId,
|
||||
Id = p32.OrderDelivery.Id,
|
||||
CreatedAt = p32.OrderDelivery.CreatedAt
|
||||
},
|
||||
Id = p32.Id,
|
||||
CreatedAt = p32.CreatedAt
|
||||
};
|
||||
public static Order AdaptToOrder(this OrderSDto p35)
|
||||
{
|
||||
|
@ -453,53 +472,20 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<OrderDelivery> funcMain2(List<OrderDeliverySDto> p3)
|
||||
private static List<Payment> funcMain2(List<PaymentSDto> p3)
|
||||
{
|
||||
if (p3 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderDelivery> result = new List<OrderDelivery>(p3.Count);
|
||||
List<Payment> result = new List<Payment>(p3.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p3.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDeliverySDto item = p3[i];
|
||||
result.Add(item == null ? null : new OrderDelivery()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
ShippingId = item.ShippingId,
|
||||
Shipping = new Shipping() {Id = item.ShippingId},
|
||||
OrderId = item.OrderId,
|
||||
Order = new Order() {Id = item.OrderId},
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<Payment> funcMain3(List<PaymentSDto> p4)
|
||||
{
|
||||
if (p4 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Payment> result = new List<Payment>(p4.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p4.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PaymentSDto item = p4[i];
|
||||
PaymentSDto item = p3[i];
|
||||
result.Add(item == null ? null : new Payment()
|
||||
{
|
||||
FactorNumber = item.FactorNumber,
|
||||
|
@ -527,29 +513,50 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static ApplicationUser funcMain4(Never p7, ApplicationUser p8, OrderLDto p5)
|
||||
private static ApplicationUser funcMain3(Never p6, ApplicationUser p7, OrderLDto p4)
|
||||
{
|
||||
ApplicationUser result = p8 ?? new ApplicationUser();
|
||||
ApplicationUser result = p7 ?? new ApplicationUser();
|
||||
|
||||
result.PhoneNumber = p5.UserPhoneNumber;
|
||||
result.PhoneNumber = p4.UserPhoneNumber;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<OrderProduct> funcMain5(List<OrderProductSDto> p9, List<OrderProduct> p10)
|
||||
private static OrderDelivery funcMain4(OrderDeliverySDto p8, OrderDelivery p9)
|
||||
{
|
||||
if (p9 == null)
|
||||
if (p8 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderProduct> result = new List<OrderProduct>(p9.Count);
|
||||
OrderDelivery result = p9 ?? new OrderDelivery();
|
||||
|
||||
result.AddressId = p8.AddressId;
|
||||
result.Address = p8.Address == null ? null : (UserAddress)Convert.ChangeType((object)p8.Address, typeof(UserAddress));
|
||||
result.DeliveryCost = p8.DeliveryCost;
|
||||
result.ShippingId = p8.ShippingId;
|
||||
result.Shipping = funcMain5(new Never(), result.Shipping, p8);
|
||||
result.OrderId = p8.OrderId;
|
||||
result.Order = funcMain6(new Never(), result.Order, p8);
|
||||
result.Id = p8.Id;
|
||||
result.CreatedAt = p8.CreatedAt;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<OrderProduct> funcMain7(List<OrderProductSDto> p14, List<OrderProduct> p15)
|
||||
{
|
||||
if (p14 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderProduct> result = new List<OrderProduct>(p14.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p9.Count;
|
||||
int len = p14.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderProductSDto item = p9[i];
|
||||
OrderProductSDto item = p14[i];
|
||||
result.Add(item == null ? null : new OrderProduct()
|
||||
{
|
||||
Count = item.Count,
|
||||
|
@ -577,53 +584,20 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<OrderDelivery> funcMain6(List<OrderDeliverySDto> p11, List<OrderDelivery> p12)
|
||||
private static List<Payment> funcMain8(List<PaymentSDto> p16, List<Payment> p17)
|
||||
{
|
||||
if (p11 == null)
|
||||
if (p16 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderDelivery> result = new List<OrderDelivery>(p11.Count);
|
||||
List<Payment> result = new List<Payment>(p16.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p11.Count;
|
||||
int len = p16.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDeliverySDto item = p11[i];
|
||||
result.Add(item == null ? null : new OrderDelivery()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
ShippingId = item.ShippingId,
|
||||
Shipping = new Shipping() {Id = item.ShippingId},
|
||||
OrderId = item.OrderId,
|
||||
Order = new Order() {Id = item.OrderId},
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<Payment> funcMain7(List<PaymentSDto> p13, List<Payment> p14)
|
||||
{
|
||||
if (p13 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Payment> result = new List<Payment>(p13.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p13.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PaymentSDto item = p13[i];
|
||||
PaymentSDto item = p16[i];
|
||||
result.Add(item == null ? null : new Payment()
|
||||
{
|
||||
FactorNumber = item.FactorNumber,
|
||||
|
@ -651,125 +625,20 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<OrderProductSDto> funcMain8(List<OrderProduct> p20)
|
||||
{
|
||||
if (p20 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderProductSDto> result = new List<OrderProductSDto>(p20.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p20.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderProduct item = p20[i];
|
||||
result.Add(item == null ? null : new OrderProductSDto()
|
||||
{
|
||||
Count = item.Count,
|
||||
ProductFee = item.ProductFee,
|
||||
ProductFeeWithDiscount = item.ProductFeeWithDiscount,
|
||||
HasDiscount = item.HasDiscount,
|
||||
ProductCost = item.ProductCost,
|
||||
PackingFee = item.PackingFee,
|
||||
PackingCost = item.PackingCost,
|
||||
OrderProductStatus = item.OrderProductStatus,
|
||||
ProductId = item.ProductId,
|
||||
ProductName = item.Product != null ? item.Product.PersianName : string.Empty,
|
||||
OrderId = item.OrderId,
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<OrderDeliverySDto> funcMain9(List<OrderDelivery> p21)
|
||||
{
|
||||
if (p21 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(p21.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p21.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDelivery item = p21[i];
|
||||
result.Add(item == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty,
|
||||
OrderId = item.OrderId,
|
||||
ShippingId = item.ShippingId,
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PaymentSDto> funcMain10(List<Payment> p22)
|
||||
private static List<OrderProductSDto> funcMain9(List<OrderProduct> p22)
|
||||
{
|
||||
if (p22 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PaymentSDto> result = new List<PaymentSDto>(p22.Count);
|
||||
List<OrderProductSDto> result = new List<OrderProductSDto>(p22.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p22.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
Payment item = p22[i];
|
||||
result.Add(item == null ? null : new PaymentSDto()
|
||||
{
|
||||
FactorNumber = item.FactorNumber,
|
||||
Amount = item.Amount,
|
||||
Description = item.Description,
|
||||
TransactionCode = item.TransactionCode,
|
||||
CardPan = item.CardPan,
|
||||
Authority = item.Authority,
|
||||
Type = item.Type,
|
||||
Status = item.Status,
|
||||
OrderId = item.OrderId,
|
||||
UserId = item.UserId,
|
||||
UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty,
|
||||
UserPhoneNumber = item.User != null ? item.User.PhoneNumber : string.Empty,
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<OrderProductSDto> funcMain11(List<OrderProduct> p25, List<OrderProductSDto> p26)
|
||||
{
|
||||
if (p25 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderProductSDto> result = new List<OrderProductSDto>(p25.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p25.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderProduct item = p25[i];
|
||||
OrderProduct item = p22[i];
|
||||
result.Add(item == null ? null : new OrderProductSDto()
|
||||
{
|
||||
Count = item.Count,
|
||||
|
@ -792,52 +661,20 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<OrderDeliverySDto> funcMain12(List<OrderDelivery> p27, List<OrderDeliverySDto> p28)
|
||||
private static List<PaymentSDto> funcMain10(List<Payment> p23)
|
||||
{
|
||||
if (p27 == null)
|
||||
if (p23 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(p27.Count);
|
||||
List<PaymentSDto> result = new List<PaymentSDto>(p23.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p27.Count;
|
||||
int len = p23.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDelivery item = p27[i];
|
||||
result.Add(item == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
Address = item.Address,
|
||||
PostalCode = item.PostalCode,
|
||||
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
|
||||
ReceiverFullName = item.ReceiverFullName,
|
||||
ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty,
|
||||
OrderId = item.OrderId,
|
||||
ShippingId = item.ShippingId,
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PaymentSDto> funcMain13(List<Payment> p29, List<PaymentSDto> p30)
|
||||
{
|
||||
if (p29 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PaymentSDto> result = new List<PaymentSDto>(p29.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p29.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
Payment item = p29[i];
|
||||
Payment item = p23[i];
|
||||
result.Add(item == null ? null : new PaymentSDto()
|
||||
{
|
||||
FactorNumber = item.FactorNumber,
|
||||
|
@ -861,6 +698,99 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<OrderProductSDto> funcMain11(List<OrderProduct> p26, List<OrderProductSDto> p27)
|
||||
{
|
||||
if (p26 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderProductSDto> result = new List<OrderProductSDto>(p26.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p26.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderProduct item = p26[i];
|
||||
result.Add(item == null ? null : new OrderProductSDto()
|
||||
{
|
||||
Count = item.Count,
|
||||
ProductFee = item.ProductFee,
|
||||
ProductFeeWithDiscount = item.ProductFeeWithDiscount,
|
||||
HasDiscount = item.HasDiscount,
|
||||
ProductCost = item.ProductCost,
|
||||
PackingFee = item.PackingFee,
|
||||
PackingCost = item.PackingCost,
|
||||
OrderProductStatus = item.OrderProductStatus,
|
||||
ProductId = item.ProductId,
|
||||
ProductName = item.Product != null ? item.Product.PersianName : string.Empty,
|
||||
OrderId = item.OrderId,
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PaymentSDto> funcMain12(List<Payment> p28, List<PaymentSDto> p29)
|
||||
{
|
||||
if (p28 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PaymentSDto> result = new List<PaymentSDto>(p28.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p28.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
Payment item = p28[i];
|
||||
result.Add(item == null ? null : new PaymentSDto()
|
||||
{
|
||||
FactorNumber = item.FactorNumber,
|
||||
Amount = item.Amount,
|
||||
Description = item.Description,
|
||||
TransactionCode = item.TransactionCode,
|
||||
CardPan = item.CardPan,
|
||||
Authority = item.Authority,
|
||||
Type = item.Type,
|
||||
Status = item.Status,
|
||||
OrderId = item.OrderId,
|
||||
UserId = item.UserId,
|
||||
UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty,
|
||||
UserPhoneNumber = item.User != null ? item.User.PhoneNumber : string.Empty,
|
||||
Id = item.Id,
|
||||
CreatedAt = item.CreatedAt
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static OrderDeliverySDto funcMain13(OrderDelivery p30, OrderDeliverySDto p31)
|
||||
{
|
||||
if (p30 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
OrderDeliverySDto result = p31 ?? new OrderDeliverySDto();
|
||||
|
||||
result.Address = p30.Address == null ? null : p30.Address.ToString();
|
||||
result.ShippingMethod = p30.Shipping != null ? p30.Shipping.Name : string.Empty;
|
||||
result.DeliveryCost = p30.DeliveryCost;
|
||||
result.AddressId = p30.AddressId;
|
||||
result.OrderId = p30.OrderId;
|
||||
result.ShippingId = p30.ShippingId;
|
||||
result.Id = p30.Id;
|
||||
result.CreatedAt = p30.CreatedAt;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static ApplicationUser funcMain14(Never p38, ApplicationUser p39, OrderSDto p36)
|
||||
{
|
||||
ApplicationUser result = p39 ?? new ApplicationUser();
|
||||
|
@ -870,5 +800,23 @@ namespace NetinaShop.Domain.Mappers
|
|||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static Shipping funcMain5(Never p10, Shipping p11, OrderDeliverySDto p8)
|
||||
{
|
||||
Shipping result = p11 ?? new Shipping();
|
||||
|
||||
result.Id = p8.ShippingId;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static Order funcMain6(Never p12, Order p13, OrderDeliverySDto p8)
|
||||
{
|
||||
Order result = p13 ?? new Order();
|
||||
|
||||
result.Id = p8.OrderId;
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
@ -26,12 +27,13 @@ public class GetOrderQueryHandler : IRequestHandler<GetOrderQuery, Order>
|
|||
|
||||
orderProducts.ForEach(op => order.AddOrderProduct(op));
|
||||
|
||||
var orderDeliveries = await _repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
var orderDelivery= await _repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.TableNoTracking
|
||||
.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));
|
||||
.FirstOrDefaultAsync(od => od.OrderId == request.Id, cancellationToken);
|
||||
if (orderDelivery != null)
|
||||
{
|
||||
order.AddOrderDelivery(orderDelivery.AddressId, orderDelivery.DeliveryCost, orderDelivery.ShippingId, orderDelivery.OrderId, orderDelivery.Id);
|
||||
}
|
||||
|
||||
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: "");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,41 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NetinaShop.Repository.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EditOrderDelivey : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_OrderDeliveries_OrderId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderDeliveries_OrderId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
column: "OrderId",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_OrderDeliveries_OrderId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderDeliveries_OrderId",
|
||||
schema: "public",
|
||||
table: "OrderDeliveries",
|
||||
column: "OrderId");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,7 +569,10 @@ namespace NetinaShop.Repository.Migrations
|
|||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.HasIndex("OrderId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("ShippingId");
|
||||
|
||||
|
@ -1115,6 +1105,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 +1134,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 +1259,9 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("WorkingDays")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shippings", "public");
|
||||
|
@ -1418,9 +1427,14 @@ 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")
|
||||
.WithOne("OrderDelivery")
|
||||
.HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping")
|
||||
|
@ -1428,6 +1442,8 @@ namespace NetinaShop.Repository.Migrations
|
|||
.HasForeignKey("ShippingId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.Navigation("Address");
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Shipping");
|
||||
|
@ -1620,7 +1636,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
|
||||
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b =>
|
||||
{
|
||||
b.Navigation("OrderDeliveries");
|
||||
b.Navigation("OrderDelivery");
|
||||
|
||||
b.Navigation("OrderProducts");
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue