add version 0.0.0.1

complete basic controller , complet basic entities , complete authorize , complete commands and queries , complete cqrs and handlers
release
Amir Hossein Khademi 2023-12-31 19:55:22 +03:30
parent 042c9fb9c7
commit 0a1c080581
92 changed files with 2182 additions and 1064 deletions

1
.version 100644
View File

@ -0,0 +1 @@
0.0.0.1

View File

@ -12,6 +12,9 @@
"Microsoft.AspNetCore.Http.Connections": "Debug"
}
},
"ShopSettings": {
"TaxesFee": 9
},
"SiteSettings": {
"BaseUrl": "http://localhost:32770",
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",

View File

@ -11,6 +11,7 @@ public class AuthController : ICarterModule
group.MapPost("login/password", LoginWithPassword)
.WithDisplayName("LoginWithPassword")
.HasApiVersion(1.0);
group.MapPost("login/swagger", LoginSwagger)
.WithDisplayName("LoginSwagger")
.HasApiVersion(1.0);

View File

@ -1,7 +1,4 @@
using MediatR;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace NetinaShop.Api.Controller;
namespace NetinaShop.Api.Controller;
public class DiscountController : ICarterModule
{

View File

@ -0,0 +1,60 @@
using NetinaShop.Domain.Enums;
namespace NetinaShop.Api.Controller;
public class OrderBagController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("OrderBag")
.MapGroup("api/order/bag")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
group.MapGet("", GetUserCurrentOrderBagAsync)
.WithDisplayName("GetUserCurrentOrderBagAsync")
.HasApiVersion(1.0);
group.MapPost("add/{productId}", AddProductToBagAsync)
.WithDisplayName("AddProductToBag")
.HasApiVersion(1.0);
group.MapPost("remove/{productId}", RemoveFromOrderBagAsync)
.WithDisplayName("RemoveFromOrderBag")
.HasApiVersion(1.0);
group.MapPost("discount/{orderId}", AddDiscountToOrderBagAsync)
.WithDisplayName("AddDiscountToOrderBag")
.HasApiVersion(1.0);
group.MapPost("shipping/{orderId}", AddShippingToOrderBagAsync)
.WithDisplayName("AddShippingToOrderBag")
.HasApiVersion(1.0);
group.MapPost("payment/{orderId}", SubmitOrderPaymentAsync)
.WithDisplayName("SubmitOrderPayment")
.HasApiVersion(1.0);
}
public async Task<IResult> GetUserCurrentOrderBagAsync(IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetUserOrderBagQuery(), cancellationToken));
public async Task<IResult> AddProductToBagAsync( Guid productId, [FromQuery]int count, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new AddToOrderBagCommand(productId,count), cancellationToken));
public async Task<IResult> RemoveFromOrderBagAsync(Guid productId, [FromQuery] int count, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new RemoveFromOrderBagCommand(productId, count), cancellationToken));
public async Task<IResult> AddDiscountToOrderBagAsync(Guid orderId, [FromQuery] string discountCode, IMediator mediator, CancellationToken cancellationToken)
=> 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));
public async Task<IResult> SubmitOrderPaymentAsync(Guid orderId, [FromQuery] OrderPaymentMethod paymentMethod, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok( await mediator.Send(new SubmitOrderPaymentCommand(orderId, paymentMethod), cancellationToken));
}

View File

@ -0,0 +1,32 @@
namespace NetinaShop.Api.Controller;
public class OrderController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("Order")
.MapGroup("api/order")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
group.MapGet("", GetAllAsync)
.WithDisplayName("GetAllOrders")
.HasApiVersion(1.0);
group.MapGet("{id}", GetAsync)
.WithDisplayName("GetOneOrder")
.HasApiVersion(1.0);
group.MapDelete("{id}", DeleteAsync)
.WithDisplayName("DeleteOneOrder")
.HasApiVersion(1.0);
}
public async Task<IResult> GetAllAsync(IMediator mediator, [FromQuery] int page = 0, CancellationToken cancellationToken = default)
=> TypedResults.Ok(await mediator.Send(new GetOrdersQuery(page), cancellationToken));
public async Task<IResult> GetAsync(IMediator mediator,Guid id, CancellationToken cancellationToken = default)
=> TypedResults.Ok(await mediator.Send(new GetOrderLDtoQuery(id), cancellationToken));
public async Task<IResult> DeleteAsync(IMediator mediator, Guid id, CancellationToken cancellationToken = default)
=> TypedResults.Ok(await mediator.Send(new DeleteOrderCommand(id), cancellationToken));
}

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Products;
namespace NetinaShop.Api.Controller;
namespace NetinaShop.Api.Controller;
public class ProductController : ICarterModule
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Api.Controller;
namespace NetinaShop.Api.Controller;
public class ShippingController : ICarterModule
{
@ -30,12 +28,12 @@ public class ShippingController : ICarterModule
}
// GET:Get All Entity
public async Task<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Shipping>().TableNoTracking.OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10).ToListAsync(cancellationToken));
public async Task<IResult> GetAllAsync([FromQuery] int page, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetShippingsQuery(page),cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Shipping>().TableNoTracking.Where(b => b.Id == id).FirstOrDefaultAsync(cancellationToken));
public async Task<IResult> GetAsync(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetShippingQuery(id), cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] CreateShippingCommand request, IMediator mediator, CancellationToken cancellationToken)

View File

@ -14,6 +14,7 @@ if (builder.Environment.IsProduction())
var configuration = builder.Configuration;
var siteSetting = configuration.GetSection(nameof(SiteSettings)).Get<SiteSettings>();
builder.Services.Configure<SiteSettings>(configuration.GetSection(nameof(SiteSettings)));
builder.Services.Configure<ShopSettings>(configuration.GetSection(nameof(ShopSettings)));

View File

@ -94,13 +94,16 @@ public class ExceptionHandlerMiddleware
if (_env.IsDevelopment())
{
var dic = new Dictionary<string, string>
if (exception?.InnerException?.Message != null)
{
["Exception"] = exception.Message,
["InnerException"] = exception.InnerException?.Message,
["StackTrace"] = exception.StackTrace
};
message = JsonConvert.SerializeObject(dic);
var dic = new Dictionary<string, string>
{
["Exception"] = exception.Message,
["InnerException"] = exception?.InnerException?.Message,
["StackTrace"] = exception?.StackTrace
};
message = JsonConvert.SerializeObject(dic);
}
}
message = exception.Message;

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using System.Reflection;
namespace NetinaShop.Common.Extensions
{

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using System.Reflection;
namespace NetinaShop.Common.Extensions
{

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Net;
namespace NetinaShop.Common.Models.Api
{

View File

@ -25,14 +25,14 @@ public abstract class ApiEntity : IApiEntity , IEquatable<ApiEntity>
public bool Equals(ApiEntity? other)
public bool Equals(ApiEntity other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Id.Equals(other.Id);
}
public override bool Equals(object? obj)
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;

View File

@ -24,7 +24,6 @@
<ItemGroup>
<Folder Include="Abstracts\" />
<Folder Include="BaseServices\Abstracts\" />
<Folder Include="CoreServices\Abstracts\" />
<Folder Include="Models\Api\" />
</ItemGroup>

View File

@ -39,4 +39,6 @@ public sealed record UpdateDiscountCommand(Guid Id,
Guid ProductId,
Guid CategoryId) : IRequest<bool>;
public sealed record DeleteDiscountCommand(Guid Id) : IRequest<bool>;
public sealed record DeleteDiscountCommand(Guid Id) : IRequest<bool>;
public sealed record CalculateDiscountCommand(string DiscountCode,Order Order) : IRequest<double>;

View File

@ -0,0 +1,12 @@
namespace NetinaShop.Domain.CommandQueries.Commands;
public sealed record CreateOrderCommand(string DiscountCode, List<OrderProductSDto> OrderProducts, OrderDeliverySDto OrderDelivery) : IRequest<OrderSDto>;
public sealed record AddToOrderBagCommand(Guid ProductId, int Count) : IRequest<bool>;
public sealed record RemoveFromOrderBagCommand(Guid ProductId, int Count) : IRequest<bool>;
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 SubmitOrderPaymentCommand(Guid OrderId, OrderPaymentMethod PaymentMethod) : IRequest<SubmitOrderPaymentResponseDto>;

View File

@ -0,0 +1,7 @@
namespace NetinaShop.Domain.CommandQueries.Commands;
public sealed record CreateBaseOrderCommand(Guid UserId) : IRequest<Order>;
public sealed record CalculateOrderCommand(Guid OrderId) : IRequest<Order>;
public sealed record DeleteOrderCommand(Guid OrderId) : IRequest<bool>;

View File

@ -7,9 +7,12 @@ string Summery,
string ExpertCheck,
string Tags,
string Warranty,
bool BeDisplayed,
double Cost,
double PackingCost,
Guid BrandId,
string BrandNames ,
List<Guid> Categories,
Guid CategoryId,
List<SpecificationSDto> Specifications,
List<StorageFileSDto> Files):IRequest<ProductLDto>;
@ -21,9 +24,12 @@ public sealed record UpdateProductCommand(
string ExpertCheck,
string Tags,
string Warranty,
bool BeDisplayed,
double Cost,
double PackingCost,
Guid BrandId,
string BrandNames,
List<Guid> Categories,
Guid CategoryId,
List<SpecificationSDto> Specifications,
List<StorageFileSDto> Files) : IRequest<bool>;
public sealed record DeleteProductCommand(Guid Id) : IRequest<bool>;

View File

@ -5,7 +5,8 @@ public sealed record CreateShippingCommand (
string WarehouseName,
bool IsFastShipping ,
bool IsShipBySeller ,
bool IsOriginalWarehouse) : IRequest<ShippingSDto>;
bool IsOriginalWarehouse,
double DeliveryCost) : IRequest<ShippingSDto>;
public sealed record UpdateShippingCommand(
Guid Id,
@ -13,7 +14,8 @@ public sealed record UpdateShippingCommand(
string WarehouseName,
bool IsFastShipping,
bool IsShipBySeller,
bool IsOriginalWarehouse) : IRequest<bool>;
bool IsOriginalWarehouse,
double DeliveryCost) : IRequest<bool>;
public sealed record DeleteShippingCommand(
Guid Id) : IRequest<bool>;

View File

@ -0,0 +1,3 @@
namespace NetinaShop.Domain.CommandQueries.Queries;
public record GetUserOrderBagQuery() : IRequest<Order>;

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.CommandQueries.Queries;
public sealed record GetOrderLDtoQuery(Guid Id) : IRequest<OrderLDto>;
public sealed record GetOrderQuery(Guid Id) : IRequest<Order>;
public sealed record GetOrdersQuery(int Page = 0) : IRequest<List<OrderSDto>>;

View File

@ -0,0 +1,4 @@
namespace NetinaShop.Domain.CommandQueries.Queries;
public sealed record GetShippingsQuery(int Page = 0) : IRequest<List<ShippingSDto>>;
public sealed record GetShippingQuery(Guid Id) : IRequest<ShippingSDto>;

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain.Dtos.LargDtos;
namespace NetinaShop.Domain.Dtos.LargDtos;
public class BrandLDto : BaseDto<BrandLDto,Brand>
{

View File

@ -0,0 +1,22 @@
namespace NetinaShop.Domain.Dtos.LargDtos;
public class OrderLDto : BaseDto<OrderLDto,Order>
{
public long TotalPrice { get; set; }
public long DeliveryPrice { get; set; }
public long TaxesPrice { get; set; }
public long ServicePrice { get; set; }
public long PackingPrice { get; set; }
public long TotalProductsPrice { get; set; }
public long DiscountPrice { get; set; }
public bool IsPayed { get; set; }
public OrderStatus OrderStatus { get; set; }
public DateTime DoneAt { get; set; }
public DateTime OrderAt { get; set; }
public int PreparingMinute { get; set; }
public string DiscountCode { get; set; } = string.Empty;
public List<OrderProductSDto> OrderProducts { get; internal set; } = new();
public List<OrderDeliverySDto> OrderDeliveries { get; internal set; } = new();
}

View File

@ -13,6 +13,6 @@ public class ProductLDto : BaseDto<ProductLDto,Product>
public List<SpecificationSDto> Specifications { get; set; } = new();
public List<ReviewSDto> Reviews { get; set; } = new();
public List<ProductCategorySDto> Categories { get; set; } = new();
public List<CategorySDto> Categories { get; set; } = new();
public List<StorageFileSDto> Files { get; set; } = new();
}

View File

@ -0,0 +1,7 @@
namespace NetinaShop.Domain.Dtos.RequestDtos;
public class OrderProductRequestDto
{
public int Count { get; internal set; }
public Guid ProductId { get; internal set; }
}

View File

@ -0,0 +1,7 @@
namespace NetinaShop.Domain.Dtos.ResponseDtos;
public class SubmitOrderPaymentResponseDto
{
public string PaymentUrl { get; set; } = string.Empty;
public bool NeedToPayOnline { get; set; }
}

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Blogs;
namespace NetinaShop.Domain.Dtos.SmallDtos;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class BlogSDto : BaseDto<BlogSDto , Blog>
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain.Dtos.SmallDtos;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class BrandSDto : BaseDto<BrandSDto , Brand>
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Discounts;
namespace NetinaShop.Domain.Dtos.SmallDtos;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class DiscountSDto : BaseDto<DiscountSDto,Discount>
{

View File

@ -0,0 +1,12 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class OrderDeliverySDto : BaseDto<OrderDeliverySDto, OrderDelivery>
{
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 Guid OrderId { get; set; }
public Guid ShippingId { get; internal set; }
}

View File

@ -0,0 +1,14 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class OrderProductSDto : BaseDto<OrderProductSDto, OrderProduct>
{
public int Count { get; internal set; }
public float ProductFee { get; internal set; }
public float ProductCost { get; internal set; }
public OrderStatus OrderProductStatus { get; internal set; }
public Guid ProductId { get; internal set; }
public Guid OrderId { get; internal set; }
}

View File

@ -0,0 +1,17 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class OrderSDto : BaseDto<OrderSDto, Order>
{
public long TotalPrice { get; set; }
public long DeliveryPrice { get; set; }
public long TaxesPrice { get; set; }
public long ServicePrice { get; set; }
public long PackingPrice { get; set; }
public long TotalProductsPrice { get; set; }
public long DiscountPrice { get; set; }
public bool IsPayed { get; set; }
public OrderStatus OrderStatus { get; set; }
public DateTime DoneAt { get; set; }
public DateTime OrderAt { get; set; }
public int PreparingMinute { get; set; }
public string DiscountCode { get; set; } = string.Empty;
}

View File

@ -1,9 +0,0 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class ProductCategorySDto : BaseDto<ProductCategorySDto, ProductCategory>
{
public Guid CategoryId { get; set; }
public string CategoryName { get; set; } = string.Empty;
public Guid ProductId { get; set; }
}

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Domain.Dtos.SmallDtos;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class ShippingSDto : BaseDto<ShippingSDto,Shipping>
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.StorageFiles;
namespace NetinaShop.Domain.Dtos.SmallDtos;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class StorageFileSDto : BaseDto<StorageFileSDto , StorageFile>
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.StorageFiles;
namespace NetinaShop.Domain.Entities.Blogs;
namespace NetinaShop.Domain.Entities.Blogs;
public partial class Blog
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.StorageFiles;
namespace NetinaShop.Domain.Entities.Blogs;
namespace NetinaShop.Domain.Entities.Blogs;
public partial class BlogStorageFile : StorageFile
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.StorageFiles;
namespace NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain.Entities.Brands;
public partial class BrandStorageFile : StorageFile
{

View File

@ -22,6 +22,6 @@ public partial class Category : ApiEntity
public Category? Parent { get; internal set; }
public List<Category> Children { get; internal set; } = new();
public List<ProductCategory> Products { get; internal set; } = new();
public List<Product> Products { get; internal set; } = new();
public List<CategoryStorageFile> Files { get; internal set; } = new();
}

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.StorageFiles;
namespace NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Domain.Entities.Categories;
public partial class CategoryStorageFile : StorageFile
{

View File

@ -0,0 +1,112 @@
namespace NetinaShop.Domain.Entities.Orders;
public partial class Order
{
public static Order Create(Guid userId)
{
return new Order(0, 0, 0, 0, 0, 0, 0, false, OrderStatus.OrderBag, DateTime.MinValue, DateTime.MinValue, 0, string.Empty, userId, OrderPaymentMethod.OnlinePayment);
}
public void AddToOrderBag(Product product, int count)
{
var orderProduct = OrderProducts.FirstOrDefault(op => op.ProductId == product.Id);
if (orderProduct == null)
{
orderProduct = OrderProduct.Create(count, product.Cost,product.PackingCost, OrderStatus.OrderBag, product.Id,product.CategoryId, this.Id);
OrderProducts.Add(orderProduct);
}
else
{
orderProduct.SetCount(count);
}
}
public void RemoveFromOrderBag(Product product, int count)
{
var orderProduct = OrderProducts.FirstOrDefault(op => op.ProductId == product.Id);
if (orderProduct != null)
{
orderProduct.SetCount(count);
if (orderProduct.Count == 0)
OrderProducts.Remove(orderProduct);
}
}
public void SetDiscount(string discountCode)
=> DiscountCode = discountCode;
public void AddOrderProduct(OrderProduct orderProduct)
=> OrderProducts.Add(orderProduct);
public void SetSubmitOrder(OrderPaymentMethod paymentMethod)
{
switch (paymentMethod)
{
case OrderPaymentMethod.OnlinePayment:
OrderStatus = OrderStatus.Paid;
IsPayed = true;
PayedAt = DateTime.Now;
OrderAt = DateTime.Now;
PaymentMethod = paymentMethod;
break;
case OrderPaymentMethod.CardTransfer:
OrderStatus = OrderStatus.Submitted;
IsPayed = false;
OrderAt = DateTime.Now;
PaymentMethod = paymentMethod;
break;
case OrderPaymentMethod.Cash:
OrderStatus = OrderStatus.Submitted;
IsPayed = false;
OrderAt = DateTime.Now;
PaymentMethod = paymentMethod;
break;
}
}
public void AddOrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId)
{
var orderDelivery = OrderDelivery.Create(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId);
OrderDeliveries.Add(orderDelivery);
}
public void SetTotalPrice(double totalProductPrice,
double packingPrice,
double servicePrice,
double deliveryPrice,
double discountPrice,
double taxesPrice)
{
TotalProductsPrice = totalProductPrice;
PackingPrice = packingPrice;
ServicePrice = servicePrice;
DeliveryPrice = deliveryPrice;
TaxesPrice = taxesPrice;
DiscountPrice = discountPrice;
TotalPrice = (totalProductPrice + packingPrice + servicePrice + deliveryPrice + taxesPrice) - discountPrice;
}
}
public partial class OrderProduct
{
public static OrderProduct Create(int count, double productFee, double packingFee, OrderStatus orderProductStatus, Guid productId, Guid productCategoryId, Guid orderId)
{
var productCost = count * productFee;
var packingCost = count * packingFee;
return new OrderProduct(count, productFee, productCost,packingFee,packingCost, orderProductStatus, productId,productCategoryId, orderId);
}
public void SetCount(int count)
{
Count = count;
var productCost = ProductFee * Count;
}
}
public partial class OrderDelivery
{
public static OrderDelivery Create(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId)
{
return new OrderDelivery(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId);
}
}

View File

@ -1,20 +1,63 @@
namespace NetinaShop.Domain.Entities.Orders;
public class Order : ApiEntity
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[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 Order : ApiEntity
{
public long TotalPrice { get; internal set; }
public long DeliveryPrice { get; internal set; }
public long TaxesPrice { get; internal set; }
public long ServicePrice { get; internal set; }
public long PackingPrice { get; internal set; }
public long TotalProductsPrice { get; internal set; }
public long DiscountPrice { get; internal set; }
public Order()
{
}
public Order(
double totalPrice,
double deliveryPrice,
double taxesPrice,
double servicePrice,
double packingPrice,
double totalProductsPrice,
double discountPrice,
bool isPayed, OrderStatus orderStatus, DateTime doneAt, DateTime orderAt, int preparingMinute, string discountCode, Guid userId, OrderPaymentMethod paymentMethod)
{
TotalPrice = totalPrice;
DeliveryPrice = deliveryPrice;
TaxesPrice = taxesPrice;
ServicePrice = servicePrice;
PackingPrice = packingPrice;
TotalProductsPrice = totalProductsPrice;
DiscountPrice = discountPrice;
IsPayed = isPayed;
OrderStatus = orderStatus;
DoneAt = doneAt;
OrderAt = orderAt;
PreparingMinute = preparingMinute;
DiscountCode = discountCode;
UserId = userId;
PaymentMethod = paymentMethod;
}
public double TotalProductsPrice { get; internal set; }
public double PackingPrice { get; internal set; }
public double ServicePrice { get; internal set; }
public double DeliveryPrice { get; internal set; }
public double DiscountPrice { get; internal set; }
public double TaxesPrice { get; internal set; }
public double TotalPrice { get; internal set; }
public bool IsPayed { get; internal set; }
public DateTime PayedAt { get; internal set; }
public OrderPaymentMethod PaymentMethod { get; internal set; }
public OrderStatus OrderStatus { get; internal set; }
public DateTime DoneAt { get; internal set; }
public DateTime OrderAt { get; internal set; }
public int PreparingMinute { get; internal set; }
public string DiscountCode { get; internal set; } = string.Empty;
public Guid UserId { get; internal set; }
public ApplicationUser? User { get; internal set; }
public List<OrderProduct> OrderProducts { get; internal set; } = new();
public List<OrderDelivery> OrderDeliveries { get; internal set; } = new();
}

View File

@ -1,11 +1,28 @@
namespace NetinaShop.Domain.Entities.Orders;
public class OrderDelivery : ApiEntity
public partial class OrderDelivery : ApiEntity
{
public OrderDelivery()
{
}
public OrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId)
{
Address = address;
PostalCode = postalCode;
ReceiverPhoneNumber = receiverPhoneNumber;
ReceiverFullName = receiverFullName;
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 double DeliveryCost { get; internal set; }
public Guid ShippingId { get; internal set; }
public Shipping? Shipping { get; internal set; }
public Guid OrderId { get; internal set; }
public Order? Order { get; internal set; }
}

View File

@ -1,15 +1,32 @@
using NetinaShop.Domain.Entities.Products;
namespace NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Domain.Entities.Orders;
public class OrderProduct : ApiEntity
public partial class OrderProduct : ApiEntity
{
public OrderProduct()
{
}
public OrderProduct(int count, double productFee, double productCost, double packingFee, double packingCost, OrderStatus orderProductStatus, Guid productId, Guid productCategoryId, Guid orderId)
{
Count = count;
ProductFee = productFee;
ProductCost = productCost;
OrderProductStatus = orderProductStatus;
ProductId = productId;
OrderId = orderId;
ProductCategoryId = productCategoryId;
PackingFee = packingFee;
PackingCost = packingCost;
}
public int Count { get; internal set; }
public float ProductFee { get; internal set; }
public float ProductCost { get; internal set; }
public double ProductFee { get; internal set; }
public double ProductCost { get; internal set; }
public double PackingFee { get; internal set; }
public double PackingCost { get; internal set; }
public OrderStatus OrderProductStatus { get; internal set; }
public Guid ProductId { get; internal set; }
public Guid ProductCategoryId { get; internal set; }
public Product? Product { get; internal set; }
public Guid OrderId { get; internal set; }

View File

@ -2,18 +2,10 @@
public partial class Product
{
public static Product Create(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, Guid brandId)
public static Product Create(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, bool beDisplayed, double cost, double packingCost, Guid brandId,Guid categoryId)
{
return new Product(persianName, englishName, summery, expertCheck, tags, warranty, brandId);
return new Product(persianName, englishName, summery, expertCheck, tags, warranty, beDisplayed,cost,packingCost, brandId,categoryId);
}
public ProductCategory AddCategory(Guid categoryId)
{
var ent = ProductCategory.Create(categoryId, Id);
Categories.Add(ent);
return ent;
}
public ProductStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
{
var ent = ProductStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, Id);
@ -29,14 +21,6 @@ public partial class Product
}
}
public partial class ProductCategory
{
public static ProductCategory Create(Guid categoryId, Guid productId)
{
return new ProductCategory(categoryId, productId);
}
}
public partial class ProductStorageFile
{
public static ProductStorageFile Create(string name, string fileLocation, string fileName, bool isHeader,

View File

@ -7,10 +7,10 @@ public partial class Product : ApiEntity
{
public Product()
{
}
public Product(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, Guid brandId)
public Product(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, bool beDisplayed, double cost, double packingCost, Guid brandId, Guid categoryId)
{
PersianName = persianName;
EnglishName = englishName;
@ -18,7 +18,11 @@ public partial class Product : ApiEntity
ExpertCheck = expertCheck;
Tags = tags;
Warranty = warranty;
BeDisplayed = beDisplayed;
Cost = cost;
PackingCost = packingCost;
BrandId = brandId;
CategoryId = categoryId;
}
public string PersianName { get; internal set; } = string.Empty;
public string EnglishName { get; internal set; } = string.Empty;
@ -26,13 +30,20 @@ public partial class Product : ApiEntity
public string ExpertCheck { get; internal set; } = string.Empty;
public string Tags { get; internal set; } = string.Empty;
public string Warranty { get; set; } = string.Empty;
public double Cost { get; set; }
public bool IsEnable { get; set; }
public bool BeDisplayed { get; set; }
public double PackingCost { get; set; }
public Guid BrandId { get; internal set; }
public Brand? Brand { get; set; }
public Guid CategoryId { get; internal set; }
public Category? Category { get; internal set; }
public List<Specification> Specifications { get; internal set; } = new();
public List<Review> Reviews { get; internal set; } = new();
public List<ProductCategory> Categories { get; internal set; } = new();
public List<ProductStorageFile> Files { get; internal set; } = new();
public List<OrderProduct> OrderProducts { get; internal set; } = new();
}

View File

@ -1,22 +0,0 @@
namespace NetinaShop.Domain.Entities.Products;
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[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 ProductCategory : ApiEntity
{
public ProductCategory(Guid categoryId, Guid productId)
{
CategoryId = categoryId;
ProductId = productId;
}
public ProductCategory()
{
}
public Guid CategoryId { get; internal set; }
public Category? Category { get; internal set; }
public Guid ProductId { get; internal set; }
public Product? Product { get; internal set; }
}

View File

@ -7,16 +7,16 @@ public partial class Shipping : ApiEntity
{
public Shipping()
{
}
public Shipping(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse)
public Shipping(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost)
{
Title = title;
WarehouseName = warehouseName;
IsFastShipping = isFastShipping;
IsShipBySeller = isShipBySeller;
IsOriginalWarehouse = isOriginalWarehouse;
DeliveryCost = deliveryCost;
}
public string Title { get; internal set; } = string.Empty;
@ -24,4 +24,5 @@ public partial class Shipping : ApiEntity
public bool IsFastShipping { get; internal set; }
public bool IsShipBySeller { get; internal set; }
public bool IsOriginalWarehouse { get; internal set; }
public double DeliveryCost { get; internal set; }
}

View File

@ -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)
public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost)
{
return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse);
return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse,deliveryCost);
}
}

View File

@ -0,0 +1,11 @@
namespace NetinaShop.Domain.Enums;
public enum OrderPaymentMethod
{
[Display(Name = "پرداخت درب محل")]
Cash,
[Display(Name = "پرداخت انلاین")]
OnlinePayment,
[Display(Name = "پرداخت کارت به کارت")]
CardTransfer
}

View File

@ -0,0 +1,533 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using NetinaShop.Domain.Dtos.LargDtos;
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Domain.Mappers
{
public static partial class OrderMapper
{
public static Order AdaptToOrder(this OrderLDto p1)
{
return p1 == null ? null : new Order()
{
TotalProductsPrice = (double)p1.TotalProductsPrice,
PackingPrice = (double)p1.PackingPrice,
ServicePrice = (double)p1.ServicePrice,
DeliveryPrice = (double)p1.DeliveryPrice,
DiscountPrice = (double)p1.DiscountPrice,
TaxesPrice = (double)p1.TaxesPrice,
TotalPrice = (double)p1.TotalPrice,
IsPayed = p1.IsPayed,
OrderStatus = p1.OrderStatus,
DoneAt = p1.DoneAt,
OrderAt = p1.OrderAt,
PreparingMinute = p1.PreparingMinute,
DiscountCode = p1.DiscountCode,
OrderProducts = funcMain1(p1.OrderProducts),
OrderDeliveries = funcMain2(p1.OrderDeliveries),
Id = p1.Id
};
}
public static Order AdaptTo(this OrderLDto p4, Order p5)
{
if (p4 == null)
{
return null;
}
Order result = p5 ?? new Order();
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.OrderProducts = funcMain3(p4.OrderProducts, result.OrderProducts);
result.OrderDeliveries = funcMain4(p4.OrderDeliveries, result.OrderDeliveries);
result.Id = p4.Id;
return result;
}
public static Expression<Func<OrderLDto, Order>> ProjectToOrder => p10 => new Order()
{
TotalProductsPrice = (double)p10.TotalProductsPrice,
PackingPrice = (double)p10.PackingPrice,
ServicePrice = (double)p10.ServicePrice,
DeliveryPrice = (double)p10.DeliveryPrice,
DiscountPrice = (double)p10.DiscountPrice,
TaxesPrice = (double)p10.TaxesPrice,
TotalPrice = (double)p10.TotalPrice,
IsPayed = p10.IsPayed,
OrderStatus = p10.OrderStatus,
DoneAt = p10.DoneAt,
OrderAt = p10.OrderAt,
PreparingMinute = p10.PreparingMinute,
DiscountCode = p10.DiscountCode,
OrderProducts = p10.OrderProducts.Select<OrderProductSDto, OrderProduct>(p11 => new OrderProduct()
{
Count = p11.Count,
ProductFee = (double)p11.ProductFee,
ProductCost = (double)p11.ProductCost,
OrderProductStatus = p11.OrderProductStatus,
ProductId = p11.ProductId,
OrderId = p11.OrderId,
Id = p11.Id
}).ToList<OrderProduct>(),
OrderDeliveries = p10.OrderDeliveries.Select<OrderDeliverySDto, OrderDelivery>(p12 => new OrderDelivery()
{
Address = p12.Address,
PostalCode = p12.PostalCode,
ReceiverPhoneNumber = p12.ReceiverPhoneNumber,
ReceiverFullName = p12.ReceiverFullName,
ShippingId = p12.ShippingId,
OrderId = p12.OrderId,
Id = p12.Id
}).ToList<OrderDelivery>(),
Id = p10.Id
};
public static OrderLDto AdaptToLDto(this Order p13)
{
return p13 == null ? null : new OrderLDto()
{
TotalPrice = (long)p13.TotalPrice,
DeliveryPrice = (long)p13.DeliveryPrice,
TaxesPrice = (long)p13.TaxesPrice,
ServicePrice = (long)p13.ServicePrice,
PackingPrice = (long)p13.PackingPrice,
TotalProductsPrice = (long)p13.TotalProductsPrice,
DiscountPrice = (long)p13.DiscountPrice,
IsPayed = p13.IsPayed,
OrderStatus = p13.OrderStatus,
DoneAt = p13.DoneAt,
OrderAt = p13.OrderAt,
PreparingMinute = p13.PreparingMinute,
DiscountCode = p13.DiscountCode,
OrderProducts = funcMain5(p13.OrderProducts),
OrderDeliveries = funcMain6(p13.OrderDeliveries),
Id = p13.Id
};
}
public static OrderLDto AdaptTo(this Order p16, OrderLDto p17)
{
if (p16 == null)
{
return null;
}
OrderLDto result = p17 ?? new OrderLDto();
result.TotalPrice = (long)p16.TotalPrice;
result.DeliveryPrice = (long)p16.DeliveryPrice;
result.TaxesPrice = (long)p16.TaxesPrice;
result.ServicePrice = (long)p16.ServicePrice;
result.PackingPrice = (long)p16.PackingPrice;
result.TotalProductsPrice = (long)p16.TotalProductsPrice;
result.DiscountPrice = (long)p16.DiscountPrice;
result.IsPayed = p16.IsPayed;
result.OrderStatus = p16.OrderStatus;
result.DoneAt = p16.DoneAt;
result.OrderAt = p16.OrderAt;
result.PreparingMinute = p16.PreparingMinute;
result.DiscountCode = p16.DiscountCode;
result.OrderProducts = funcMain7(p16.OrderProducts, result.OrderProducts);
result.OrderDeliveries = funcMain8(p16.OrderDeliveries, result.OrderDeliveries);
result.Id = p16.Id;
return result;
}
public static Expression<Func<Order, OrderLDto>> ProjectToLDto => p22 => new OrderLDto()
{
TotalPrice = (long)p22.TotalPrice,
DeliveryPrice = (long)p22.DeliveryPrice,
TaxesPrice = (long)p22.TaxesPrice,
ServicePrice = (long)p22.ServicePrice,
PackingPrice = (long)p22.PackingPrice,
TotalProductsPrice = (long)p22.TotalProductsPrice,
DiscountPrice = (long)p22.DiscountPrice,
IsPayed = p22.IsPayed,
OrderStatus = p22.OrderStatus,
DoneAt = p22.DoneAt,
OrderAt = p22.OrderAt,
PreparingMinute = p22.PreparingMinute,
DiscountCode = p22.DiscountCode,
OrderProducts = p22.OrderProducts.Select<OrderProduct, OrderProductSDto>(p23 => new OrderProductSDto()
{
Count = p23.Count,
ProductFee = (float)p23.ProductFee,
ProductCost = (float)p23.ProductCost,
OrderProductStatus = p23.OrderProductStatus,
ProductId = p23.ProductId,
OrderId = p23.OrderId,
Id = p23.Id
}).ToList<OrderProductSDto>(),
OrderDeliveries = p22.OrderDeliveries.Select<OrderDelivery, OrderDeliverySDto>(p24 => new OrderDeliverySDto()
{
Address = p24.Address,
PostalCode = p24.PostalCode,
ReceiverPhoneNumber = p24.ReceiverPhoneNumber,
ReceiverFullName = p24.ReceiverFullName,
OrderId = p24.OrderId,
ShippingId = p24.ShippingId,
Id = p24.Id
}).ToList<OrderDeliverySDto>(),
Id = p22.Id
};
public static Order AdaptToOrder(this OrderSDto p25)
{
return p25 == null ? null : new Order()
{
TotalProductsPrice = (double)p25.TotalProductsPrice,
PackingPrice = (double)p25.PackingPrice,
ServicePrice = (double)p25.ServicePrice,
DeliveryPrice = (double)p25.DeliveryPrice,
DiscountPrice = (double)p25.DiscountPrice,
TaxesPrice = (double)p25.TaxesPrice,
TotalPrice = (double)p25.TotalPrice,
IsPayed = p25.IsPayed,
OrderStatus = p25.OrderStatus,
DoneAt = p25.DoneAt,
OrderAt = p25.OrderAt,
PreparingMinute = p25.PreparingMinute,
DiscountCode = p25.DiscountCode,
Id = p25.Id
};
}
public static Order AdaptTo(this OrderSDto p26, Order p27)
{
if (p26 == null)
{
return null;
}
Order result = p27 ?? new Order();
result.TotalProductsPrice = (double)p26.TotalProductsPrice;
result.PackingPrice = (double)p26.PackingPrice;
result.ServicePrice = (double)p26.ServicePrice;
result.DeliveryPrice = (double)p26.DeliveryPrice;
result.DiscountPrice = (double)p26.DiscountPrice;
result.TaxesPrice = (double)p26.TaxesPrice;
result.TotalPrice = (double)p26.TotalPrice;
result.IsPayed = p26.IsPayed;
result.OrderStatus = p26.OrderStatus;
result.DoneAt = p26.DoneAt;
result.OrderAt = p26.OrderAt;
result.PreparingMinute = p26.PreparingMinute;
result.DiscountCode = p26.DiscountCode;
result.Id = p26.Id;
return result;
}
public static OrderSDto AdaptToSDto(this Order p28)
{
return p28 == null ? null : new OrderSDto()
{
TotalPrice = (long)p28.TotalPrice,
DeliveryPrice = (long)p28.DeliveryPrice,
TaxesPrice = (long)p28.TaxesPrice,
ServicePrice = (long)p28.ServicePrice,
PackingPrice = (long)p28.PackingPrice,
TotalProductsPrice = (long)p28.TotalProductsPrice,
DiscountPrice = (long)p28.DiscountPrice,
IsPayed = p28.IsPayed,
OrderStatus = p28.OrderStatus,
DoneAt = p28.DoneAt,
OrderAt = p28.OrderAt,
PreparingMinute = p28.PreparingMinute,
DiscountCode = p28.DiscountCode,
Id = p28.Id
};
}
public static OrderSDto AdaptTo(this Order p29, OrderSDto p30)
{
if (p29 == null)
{
return null;
}
OrderSDto result = p30 ?? new OrderSDto();
result.TotalPrice = (long)p29.TotalPrice;
result.DeliveryPrice = (long)p29.DeliveryPrice;
result.TaxesPrice = (long)p29.TaxesPrice;
result.ServicePrice = (long)p29.ServicePrice;
result.PackingPrice = (long)p29.PackingPrice;
result.TotalProductsPrice = (long)p29.TotalProductsPrice;
result.DiscountPrice = (long)p29.DiscountPrice;
result.IsPayed = p29.IsPayed;
result.OrderStatus = p29.OrderStatus;
result.DoneAt = p29.DoneAt;
result.OrderAt = p29.OrderAt;
result.PreparingMinute = p29.PreparingMinute;
result.DiscountCode = p29.DiscountCode;
result.Id = p29.Id;
return result;
}
public static Expression<Func<Order, OrderSDto>> ProjectToSDto => p31 => new OrderSDto()
{
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,
Id = p31.Id
};
private static List<OrderProduct> funcMain1(List<OrderProductSDto> p2)
{
if (p2 == null)
{
return null;
}
List<OrderProduct> result = new List<OrderProduct>(p2.Count);
int i = 0;
int len = p2.Count;
while (i < len)
{
OrderProductSDto item = p2[i];
result.Add(item == null ? null : new OrderProduct()
{
Count = item.Count,
ProductFee = (double)item.ProductFee,
ProductCost = (double)item.ProductCost,
OrderProductStatus = item.OrderProductStatus,
ProductId = item.ProductId,
OrderId = item.OrderId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderDelivery> funcMain2(List<OrderDeliverySDto> p3)
{
if (p3 == null)
{
return null;
}
List<OrderDelivery> result = new List<OrderDelivery>(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,
OrderId = item.OrderId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderProduct> funcMain3(List<OrderProductSDto> p6, List<OrderProduct> p7)
{
if (p6 == null)
{
return null;
}
List<OrderProduct> result = new List<OrderProduct>(p6.Count);
int i = 0;
int len = p6.Count;
while (i < len)
{
OrderProductSDto item = p6[i];
result.Add(item == null ? null : new OrderProduct()
{
Count = item.Count,
ProductFee = (double)item.ProductFee,
ProductCost = (double)item.ProductCost,
OrderProductStatus = item.OrderProductStatus,
ProductId = item.ProductId,
OrderId = item.OrderId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderDelivery> funcMain4(List<OrderDeliverySDto> p8, List<OrderDelivery> p9)
{
if (p8 == null)
{
return null;
}
List<OrderDelivery> result = new List<OrderDelivery>(p8.Count);
int i = 0;
int len = p8.Count;
while (i < len)
{
OrderDeliverySDto item = p8[i];
result.Add(item == null ? null : new OrderDelivery()
{
Address = item.Address,
PostalCode = item.PostalCode,
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
ReceiverFullName = item.ReceiverFullName,
ShippingId = item.ShippingId,
OrderId = item.OrderId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderProductSDto> funcMain5(List<OrderProduct> p14)
{
if (p14 == null)
{
return null;
}
List<OrderProductSDto> result = new List<OrderProductSDto>(p14.Count);
int i = 0;
int len = p14.Count;
while (i < len)
{
OrderProduct item = p14[i];
result.Add(item == null ? null : new OrderProductSDto()
{
Count = item.Count,
ProductFee = (float)item.ProductFee,
ProductCost = (float)item.ProductCost,
OrderProductStatus = item.OrderProductStatus,
ProductId = item.ProductId,
OrderId = item.OrderId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderDeliverySDto> funcMain6(List<OrderDelivery> p15)
{
if (p15 == null)
{
return null;
}
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(p15.Count);
int i = 0;
int len = p15.Count;
while (i < len)
{
OrderDelivery item = p15[i];
result.Add(item == null ? null : new OrderDeliverySDto()
{
Address = item.Address,
PostalCode = item.PostalCode,
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
ReceiverFullName = item.ReceiverFullName,
OrderId = item.OrderId,
ShippingId = item.ShippingId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderProductSDto> funcMain7(List<OrderProduct> p18, List<OrderProductSDto> p19)
{
if (p18 == null)
{
return null;
}
List<OrderProductSDto> result = new List<OrderProductSDto>(p18.Count);
int i = 0;
int len = p18.Count;
while (i < len)
{
OrderProduct item = p18[i];
result.Add(item == null ? null : new OrderProductSDto()
{
Count = item.Count,
ProductFee = (float)item.ProductFee,
ProductCost = (float)item.ProductCost,
OrderProductStatus = item.OrderProductStatus,
ProductId = item.ProductId,
OrderId = item.OrderId,
Id = item.Id
});
i++;
}
return result;
}
private static List<OrderDeliverySDto> funcMain8(List<OrderDelivery> p20, List<OrderDeliverySDto> p21)
{
if (p20 == null)
{
return null;
}
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(p20.Count);
int i = 0;
int len = p20.Count;
while (i < len)
{
OrderDelivery item = p20[i];
result.Add(item == null ? null : new OrderDeliverySDto()
{
Address = item.Address,
PostalCode = item.PostalCode,
ReceiverPhoneNumber = item.ReceiverPhoneNumber,
ReceiverFullName = item.ReceiverFullName,
OrderId = item.OrderId,
ShippingId = item.ShippingId,
Id = item.Id
});
i++;
}
return result;
}
}
}

View File

@ -1,66 +0,0 @@
using System;
using System.Linq.Expressions;
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Products;
namespace NetinaShop.Domain.Mappers
{
public static partial class ProductCategoryMapper
{
public static ProductCategory AdaptToProductCategory(this ProductCategorySDto p1)
{
return p1 == null ? null : new ProductCategory()
{
CategoryId = p1.CategoryId,
ProductId = p1.ProductId,
Id = p1.Id
};
}
public static ProductCategory AdaptTo(this ProductCategorySDto p2, ProductCategory p3)
{
if (p2 == null)
{
return null;
}
ProductCategory result = p3 ?? new ProductCategory();
result.CategoryId = p2.CategoryId;
result.ProductId = p2.ProductId;
result.Id = p2.Id;
return result;
}
public static ProductCategorySDto AdaptToSDto(this ProductCategory p4)
{
return p4 == null ? null : new ProductCategorySDto()
{
CategoryId = p4.CategoryId,
CategoryName = p4.Category == null ? null : p4.Category.Name,
ProductId = p4.ProductId,
Id = p4.Id
};
}
public static ProductCategorySDto AdaptTo(this ProductCategory p5, ProductCategorySDto p6)
{
if (p5 == null)
{
return null;
}
ProductCategorySDto result = p6 ?? new ProductCategorySDto();
result.CategoryId = p5.CategoryId;
result.CategoryName = p5.Category == null ? null : p5.Category.Name;
result.ProductId = p5.ProductId;
result.Id = p5.Id;
return result;
}
public static Expression<Func<ProductCategory, ProductCategorySDto>> ProjectToSDto => p7 => new ProductCategorySDto()
{
CategoryId = p7.CategoryId,
CategoryName = p7.Category.Name,
ProductId = p7.ProductId,
Id = p7.Id
};
}
}

View File

@ -23,246 +23,229 @@ namespace NetinaShop.Domain.Mappers
BrandId = p1.BrandId,
Specifications = funcMain1(p1.Specifications),
Reviews = funcMain2(p1.Reviews),
Categories = funcMain3(p1.Categories),
Files = funcMain4(p1.Files),
Files = funcMain3(p1.Files),
Id = p1.Id
};
}
public static Product AdaptTo(this ProductLDto p6, Product p7)
public static Product AdaptTo(this ProductLDto p5, Product p6)
{
if (p6 == null)
if (p5 == null)
{
return null;
}
Product result = p7 ?? new Product();
Product result = p6 ?? new Product();
result.PersianName = p6.PersianName;
result.EnglishName = p6.EnglishName;
result.Summery = p6.Summery;
result.ExpertCheck = p6.ExpertCheck;
result.Tags = p6.Tags;
result.Warranty = p6.Warranty;
result.BrandId = p6.BrandId;
result.Specifications = funcMain5(p6.Specifications, result.Specifications);
result.Reviews = funcMain6(p6.Reviews, result.Reviews);
result.Categories = funcMain7(p6.Categories, result.Categories);
result.Files = funcMain8(p6.Files, result.Files);
result.Id = p6.Id;
result.PersianName = p5.PersianName;
result.EnglishName = p5.EnglishName;
result.Summery = p5.Summery;
result.ExpertCheck = p5.ExpertCheck;
result.Tags = p5.Tags;
result.Warranty = p5.Warranty;
result.BrandId = p5.BrandId;
result.Specifications = funcMain4(p5.Specifications, result.Specifications);
result.Reviews = funcMain5(p5.Reviews, result.Reviews);
result.Files = funcMain6(p5.Files, result.Files);
result.Id = p5.Id;
return result;
}
public static Expression<Func<ProductLDto, Product>> ProjectToProduct => p16 => new Product()
public static Expression<Func<ProductLDto, Product>> ProjectToProduct => p13 => new Product()
{
PersianName = p16.PersianName,
EnglishName = p16.EnglishName,
Summery = p16.Summery,
ExpertCheck = p16.ExpertCheck,
Tags = p16.Tags,
Warranty = p16.Warranty,
BrandId = p16.BrandId,
Specifications = p16.Specifications.Select<SpecificationSDto, Specification>(p17 => new Specification()
PersianName = p13.PersianName,
EnglishName = p13.EnglishName,
Summery = p13.Summery,
ExpertCheck = p13.ExpertCheck,
Tags = p13.Tags,
Warranty = p13.Warranty,
BrandId = p13.BrandId,
Specifications = p13.Specifications.Select<SpecificationSDto, Specification>(p14 => new Specification()
{
Title = p17.Title,
Detail = p17.Detail,
Value = p17.Value,
IsFeature = p17.IsFeature,
ProductId = p17.ProductId,
ParentId = p17.ParentId,
Id = p17.Id
Title = p14.Title,
Detail = p14.Detail,
Value = p14.Value,
IsFeature = p14.IsFeature,
ProductId = p14.ProductId,
ParentId = p14.ParentId,
Id = p14.Id
}).ToList<Specification>(),
Reviews = p16.Reviews.Select<ReviewSDto, Review>(p18 => new Review()
Reviews = p13.Reviews.Select<ReviewSDto, Review>(p15 => new Review()
{
Title = p18.Title,
Comment = p18.Comment,
Rate = p18.Rate,
IsBuyer = p18.IsBuyer,
ProductId = p18.ProductId,
UserId = p18.UserId,
Id = p18.Id
Title = p15.Title,
Comment = p15.Comment,
Rate = p15.Rate,
IsBuyer = p15.IsBuyer,
ProductId = p15.ProductId,
UserId = p15.UserId,
Id = p15.Id
}).ToList<Review>(),
Categories = p16.Categories.Select<ProductCategorySDto, ProductCategory>(p19 => new ProductCategory()
Files = p13.Files.Select<StorageFileSDto, ProductStorageFile>(p16 => new ProductStorageFile()
{
CategoryId = p19.CategoryId,
ProductId = p19.ProductId,
Id = p19.Id
}).ToList<ProductCategory>(),
Files = p16.Files.Select<StorageFileSDto, ProductStorageFile>(p20 => new ProductStorageFile()
{
Name = p20.Name,
FileLocation = p20.FileLocation,
FileName = p20.FileName,
IsHeader = p20.IsHeader,
IsPrimary = p20.IsPrimary,
FileType = p20.FileType,
Id = p20.Id
Name = p16.Name,
FileLocation = p16.FileLocation,
FileName = p16.FileName,
IsHeader = p16.IsHeader,
IsPrimary = p16.IsPrimary,
FileType = p16.FileType,
Id = p16.Id
}).ToList<ProductStorageFile>(),
Id = p16.Id
Id = p13.Id
};
public static ProductLDto AdaptToLDto(this Product p21)
public static ProductLDto AdaptToLDto(this Product p17)
{
return p21 == null ? null : new ProductLDto()
return p17 == null ? null : new ProductLDto()
{
PersianName = p21.PersianName,
EnglishName = p21.EnglishName,
Summery = p21.Summery,
ExpertCheck = p21.ExpertCheck,
Tags = p21.Tags,
Warranty = p21.Warranty,
BrandId = p21.BrandId,
Specifications = funcMain9(p21.Specifications),
Reviews = funcMain10(p21.Reviews),
Categories = funcMain11(p21.Categories),
Files = funcMain12(p21.Files),
Id = p21.Id
PersianName = p17.PersianName,
EnglishName = p17.EnglishName,
Summery = p17.Summery,
ExpertCheck = p17.ExpertCheck,
Tags = p17.Tags,
Warranty = p17.Warranty,
BrandId = p17.BrandId,
Specifications = funcMain7(p17.Specifications),
Reviews = funcMain8(p17.Reviews),
Files = funcMain9(p17.Files),
Id = p17.Id
};
}
public static ProductLDto AdaptTo(this Product p26, ProductLDto p27)
public static ProductLDto AdaptTo(this Product p21, ProductLDto p22)
{
if (p26 == null)
if (p21 == null)
{
return null;
}
ProductLDto result = p27 ?? new ProductLDto();
ProductLDto result = p22 ?? new ProductLDto();
result.PersianName = p26.PersianName;
result.EnglishName = p26.EnglishName;
result.Summery = p26.Summery;
result.ExpertCheck = p26.ExpertCheck;
result.Tags = p26.Tags;
result.Warranty = p26.Warranty;
result.BrandId = p26.BrandId;
result.Specifications = funcMain13(p26.Specifications, result.Specifications);
result.Reviews = funcMain14(p26.Reviews, result.Reviews);
result.Categories = funcMain15(p26.Categories, result.Categories);
result.Files = funcMain16(p26.Files, result.Files);
result.Id = p26.Id;
result.PersianName = p21.PersianName;
result.EnglishName = p21.EnglishName;
result.Summery = p21.Summery;
result.ExpertCheck = p21.ExpertCheck;
result.Tags = p21.Tags;
result.Warranty = p21.Warranty;
result.BrandId = p21.BrandId;
result.Specifications = funcMain10(p21.Specifications, result.Specifications);
result.Reviews = funcMain11(p21.Reviews, result.Reviews);
result.Files = funcMain12(p21.Files, result.Files);
result.Id = p21.Id;
return result;
}
public static Expression<Func<Product, ProductLDto>> ProjectToLDto => p36 => new ProductLDto()
public static Expression<Func<Product, ProductLDto>> ProjectToLDto => p29 => new ProductLDto()
{
PersianName = p36.PersianName,
EnglishName = p36.EnglishName,
Summery = p36.Summery,
ExpertCheck = p36.ExpertCheck,
Tags = p36.Tags,
Warranty = p36.Warranty,
BrandId = p36.BrandId,
Specifications = p36.Specifications.Select<Specification, SpecificationSDto>(p37 => new SpecificationSDto()
PersianName = p29.PersianName,
EnglishName = p29.EnglishName,
Summery = p29.Summery,
ExpertCheck = p29.ExpertCheck,
Tags = p29.Tags,
Warranty = p29.Warranty,
BrandId = p29.BrandId,
Specifications = p29.Specifications.Select<Specification, SpecificationSDto>(p30 => new SpecificationSDto()
{
Title = p37.Title,
Detail = p37.Detail,
Value = p37.Value,
IsFeature = p37.IsFeature,
ProductId = p37.ProductId,
ParentId = p37.ParentId,
Id = p37.Id
Title = p30.Title,
Detail = p30.Detail,
Value = p30.Value,
IsFeature = p30.IsFeature,
ProductId = p30.ProductId,
ParentId = p30.ParentId,
Id = p30.Id
}).ToList<SpecificationSDto>(),
Reviews = p36.Reviews.Select<Review, ReviewSDto>(p38 => new ReviewSDto()
Reviews = p29.Reviews.Select<Review, ReviewSDto>(p31 => new ReviewSDto()
{
Title = p38.Title,
Comment = p38.Comment,
Rate = p38.Rate,
IsBuyer = p38.IsBuyer,
ProductId = p38.ProductId,
UserId = p38.UserId,
Id = p38.Id
Title = p31.Title,
Comment = p31.Comment,
Rate = p31.Rate,
IsBuyer = p31.IsBuyer,
ProductId = p31.ProductId,
UserId = p31.UserId,
Id = p31.Id
}).ToList<ReviewSDto>(),
Categories = p36.Categories.Select<ProductCategory, ProductCategorySDto>(p39 => new ProductCategorySDto()
Files = p29.Files.Select<ProductStorageFile, StorageFileSDto>(p32 => new StorageFileSDto()
{
CategoryId = p39.CategoryId,
CategoryName = p39.Category.Name,
ProductId = p39.ProductId,
Id = p39.Id
}).ToList<ProductCategorySDto>(),
Files = p36.Files.Select<ProductStorageFile, StorageFileSDto>(p40 => new StorageFileSDto()
{
Name = p40.Name,
FileLocation = p40.FileLocation,
FileName = p40.FileName,
IsHeader = p40.IsHeader,
IsPrimary = p40.IsPrimary,
FileType = p40.FileType,
Id = p40.Id
Name = p32.Name,
FileLocation = p32.FileLocation,
FileName = p32.FileName,
IsHeader = p32.IsHeader,
IsPrimary = p32.IsPrimary,
FileType = p32.FileType,
Id = p32.Id
}).ToList<StorageFileSDto>(),
Id = p36.Id
Id = p29.Id
};
public static Product AdaptToProduct(this ProductSDto p41)
public static Product AdaptToProduct(this ProductSDto p33)
{
return p41 == null ? null : new Product()
return p33 == null ? null : new Product()
{
PersianName = p41.PersianName,
EnglishName = p41.EnglishName,
Summery = p41.Summery,
ExpertCheck = p41.ExpertCheck,
Tags = p41.Tags,
Warranty = p41.Warranty,
BrandId = p41.BrandId,
Id = p41.Id
PersianName = p33.PersianName,
EnglishName = p33.EnglishName,
Summery = p33.Summery,
ExpertCheck = p33.ExpertCheck,
Tags = p33.Tags,
Warranty = p33.Warranty,
BrandId = p33.BrandId,
Id = p33.Id
};
}
public static Product AdaptTo(this ProductSDto p42, Product p43)
public static Product AdaptTo(this ProductSDto p34, Product p35)
{
if (p42 == null)
if (p34 == null)
{
return null;
}
Product result = p43 ?? new Product();
Product result = p35 ?? new Product();
result.PersianName = p42.PersianName;
result.EnglishName = p42.EnglishName;
result.Summery = p42.Summery;
result.ExpertCheck = p42.ExpertCheck;
result.Tags = p42.Tags;
result.Warranty = p42.Warranty;
result.BrandId = p42.BrandId;
result.Id = p42.Id;
result.PersianName = p34.PersianName;
result.EnglishName = p34.EnglishName;
result.Summery = p34.Summery;
result.ExpertCheck = p34.ExpertCheck;
result.Tags = p34.Tags;
result.Warranty = p34.Warranty;
result.BrandId = p34.BrandId;
result.Id = p34.Id;
return result;
}
public static ProductSDto AdaptToSDto(this Product p44)
public static ProductSDto AdaptToSDto(this Product p36)
{
return p44 == null ? null : new ProductSDto()
return p36 == null ? null : new ProductSDto()
{
PersianName = p44.PersianName,
EnglishName = p44.EnglishName,
Summery = p44.Summery,
ExpertCheck = p44.ExpertCheck,
Tags = p44.Tags,
Warranty = p44.Warranty,
BrandId = p44.BrandId,
Id = p44.Id
PersianName = p36.PersianName,
EnglishName = p36.EnglishName,
Summery = p36.Summery,
ExpertCheck = p36.ExpertCheck,
Tags = p36.Tags,
Warranty = p36.Warranty,
BrandId = p36.BrandId,
Id = p36.Id
};
}
public static ProductSDto AdaptTo(this Product p45, ProductSDto p46)
public static ProductSDto AdaptTo(this Product p37, ProductSDto p38)
{
if (p45 == null)
if (p37 == null)
{
return null;
}
ProductSDto result = p46 ?? new ProductSDto();
ProductSDto result = p38 ?? new ProductSDto();
result.PersianName = p45.PersianName;
result.EnglishName = p45.EnglishName;
result.Summery = p45.Summery;
result.ExpertCheck = p45.ExpertCheck;
result.Tags = p45.Tags;
result.Warranty = p45.Warranty;
result.BrandId = p45.BrandId;
result.Id = p45.Id;
result.PersianName = p37.PersianName;
result.EnglishName = p37.EnglishName;
result.Summery = p37.Summery;
result.ExpertCheck = p37.ExpertCheck;
result.Tags = p37.Tags;
result.Warranty = p37.Warranty;
result.BrandId = p37.BrandId;
result.Id = p37.Id;
return result;
}
public static Expression<Func<Product, ProductSDto>> ProjectToSDto => p47 => new ProductSDto()
public static Expression<Func<Product, ProductSDto>> ProjectToSDto => p39 => new ProductSDto()
{
PersianName = p47.PersianName,
EnglishName = p47.EnglishName,
Summery = p47.Summery,
ExpertCheck = p47.ExpertCheck,
Tags = p47.Tags,
Warranty = p47.Warranty,
BrandId = p47.BrandId,
Id = p47.Id
PersianName = p39.PersianName,
EnglishName = p39.EnglishName,
Summery = p39.Summery,
ExpertCheck = p39.ExpertCheck,
Tags = p39.Tags,
Warranty = p39.Warranty,
BrandId = p39.BrandId,
Id = p39.Id
};
private static List<Specification> funcMain1(List<SpecificationSDto> p2)
@ -325,46 +308,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<ProductCategory> funcMain3(List<ProductCategorySDto> p4)
private static List<ProductStorageFile> funcMain3(List<StorageFileSDto> p4)
{
if (p4 == null)
{
return null;
}
List<ProductCategory> result = new List<ProductCategory>(p4.Count);
List<ProductStorageFile> result = new List<ProductStorageFile>(p4.Count);
int i = 0;
int len = p4.Count;
while (i < len)
{
ProductCategorySDto item = p4[i];
result.Add(item == null ? null : new ProductCategory()
{
CategoryId = item.CategoryId,
ProductId = item.ProductId,
Id = item.Id
});
i++;
}
return result;
}
private static List<ProductStorageFile> funcMain4(List<StorageFileSDto> p5)
{
if (p5 == null)
{
return null;
}
List<ProductStorageFile> result = new List<ProductStorageFile>(p5.Count);
int i = 0;
int len = p5.Count;
while (i < len)
{
StorageFileSDto item = p5[i];
StorageFileSDto item = p4[i];
result.Add(item == null ? null : new ProductStorageFile()
{
Name = item.Name,
@ -381,20 +338,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<Specification> funcMain5(List<SpecificationSDto> p8, List<Specification> p9)
private static List<Specification> funcMain4(List<SpecificationSDto> p7, List<Specification> p8)
{
if (p8 == null)
if (p7 == null)
{
return null;
}
List<Specification> result = new List<Specification>(p8.Count);
List<Specification> result = new List<Specification>(p7.Count);
int i = 0;
int len = p8.Count;
int len = p7.Count;
while (i < len)
{
SpecificationSDto item = p8[i];
SpecificationSDto item = p7[i];
result.Add(item == null ? null : new Specification()
{
Title = item.Title,
@ -411,20 +368,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<Review> funcMain6(List<ReviewSDto> p10, List<Review> p11)
private static List<Review> funcMain5(List<ReviewSDto> p9, List<Review> p10)
{
if (p10 == null)
if (p9 == null)
{
return null;
}
List<Review> result = new List<Review>(p10.Count);
List<Review> result = new List<Review>(p9.Count);
int i = 0;
int len = p10.Count;
int len = p9.Count;
while (i < len)
{
ReviewSDto item = p10[i];
ReviewSDto item = p9[i];
result.Add(item == null ? null : new Review()
{
Title = item.Title,
@ -441,46 +398,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<ProductCategory> funcMain7(List<ProductCategorySDto> p12, List<ProductCategory> p13)
private static List<ProductStorageFile> funcMain6(List<StorageFileSDto> p11, List<ProductStorageFile> p12)
{
if (p12 == null)
if (p11 == null)
{
return null;
}
List<ProductCategory> result = new List<ProductCategory>(p12.Count);
List<ProductStorageFile> result = new List<ProductStorageFile>(p11.Count);
int i = 0;
int len = p12.Count;
int len = p11.Count;
while (i < len)
{
ProductCategorySDto item = p12[i];
result.Add(item == null ? null : new ProductCategory()
{
CategoryId = item.CategoryId,
ProductId = item.ProductId,
Id = item.Id
});
i++;
}
return result;
}
private static List<ProductStorageFile> funcMain8(List<StorageFileSDto> p14, List<ProductStorageFile> p15)
{
if (p14 == null)
{
return null;
}
List<ProductStorageFile> result = new List<ProductStorageFile>(p14.Count);
int i = 0;
int len = p14.Count;
while (i < len)
{
StorageFileSDto item = p14[i];
StorageFileSDto item = p11[i];
result.Add(item == null ? null : new ProductStorageFile()
{
Name = item.Name,
@ -497,20 +428,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<SpecificationSDto> funcMain9(List<Specification> p22)
private static List<SpecificationSDto> funcMain7(List<Specification> p18)
{
if (p22 == null)
if (p18 == null)
{
return null;
}
List<SpecificationSDto> result = new List<SpecificationSDto>(p22.Count);
List<SpecificationSDto> result = new List<SpecificationSDto>(p18.Count);
int i = 0;
int len = p22.Count;
int len = p18.Count;
while (i < len)
{
Specification item = p22[i];
Specification item = p18[i];
result.Add(item == null ? null : new SpecificationSDto()
{
Title = item.Title,
@ -527,20 +458,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<ReviewSDto> funcMain10(List<Review> p23)
private static List<ReviewSDto> funcMain8(List<Review> p19)
{
if (p23 == null)
if (p19 == null)
{
return null;
}
List<ReviewSDto> result = new List<ReviewSDto>(p23.Count);
List<ReviewSDto> result = new List<ReviewSDto>(p19.Count);
int i = 0;
int len = p23.Count;
int len = p19.Count;
while (i < len)
{
Review item = p23[i];
Review item = p19[i];
result.Add(item == null ? null : new ReviewSDto()
{
Title = item.Title,
@ -557,47 +488,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<ProductCategorySDto> funcMain11(List<ProductCategory> p24)
private static List<StorageFileSDto> funcMain9(List<ProductStorageFile> p20)
{
if (p24 == null)
if (p20 == null)
{
return null;
}
List<ProductCategorySDto> result = new List<ProductCategorySDto>(p24.Count);
List<StorageFileSDto> result = new List<StorageFileSDto>(p20.Count);
int i = 0;
int len = p24.Count;
int len = p20.Count;
while (i < len)
{
ProductCategory item = p24[i];
result.Add(item == null ? null : new ProductCategorySDto()
{
CategoryId = item.CategoryId,
CategoryName = item.Category == null ? null : item.Category.Name,
ProductId = item.ProductId,
Id = item.Id
});
i++;
}
return result;
}
private static List<StorageFileSDto> funcMain12(List<ProductStorageFile> p25)
{
if (p25 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(p25.Count);
int i = 0;
int len = p25.Count;
while (i < len)
{
ProductStorageFile item = p25[i];
ProductStorageFile item = p20[i];
result.Add(item == null ? null : new StorageFileSDto()
{
Name = item.Name,
@ -614,20 +518,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<SpecificationSDto> funcMain13(List<Specification> p28, List<SpecificationSDto> p29)
private static List<SpecificationSDto> funcMain10(List<Specification> p23, List<SpecificationSDto> p24)
{
if (p28 == null)
if (p23 == null)
{
return null;
}
List<SpecificationSDto> result = new List<SpecificationSDto>(p28.Count);
List<SpecificationSDto> result = new List<SpecificationSDto>(p23.Count);
int i = 0;
int len = p28.Count;
int len = p23.Count;
while (i < len)
{
Specification item = p28[i];
Specification item = p23[i];
result.Add(item == null ? null : new SpecificationSDto()
{
Title = item.Title,
@ -644,20 +548,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<ReviewSDto> funcMain14(List<Review> p30, List<ReviewSDto> p31)
private static List<ReviewSDto> funcMain11(List<Review> p25, List<ReviewSDto> p26)
{
if (p30 == null)
if (p25 == null)
{
return null;
}
List<ReviewSDto> result = new List<ReviewSDto>(p30.Count);
List<ReviewSDto> result = new List<ReviewSDto>(p25.Count);
int i = 0;
int len = p30.Count;
int len = p25.Count;
while (i < len)
{
Review item = p30[i];
Review item = p25[i];
result.Add(item == null ? null : new ReviewSDto()
{
Title = item.Title,
@ -674,47 +578,20 @@ namespace NetinaShop.Domain.Mappers
}
private static List<ProductCategorySDto> funcMain15(List<ProductCategory> p32, List<ProductCategorySDto> p33)
private static List<StorageFileSDto> funcMain12(List<ProductStorageFile> p27, List<StorageFileSDto> p28)
{
if (p32 == null)
if (p27 == null)
{
return null;
}
List<ProductCategorySDto> result = new List<ProductCategorySDto>(p32.Count);
List<StorageFileSDto> result = new List<StorageFileSDto>(p27.Count);
int i = 0;
int len = p32.Count;
int len = p27.Count;
while (i < len)
{
ProductCategory item = p32[i];
result.Add(item == null ? null : new ProductCategorySDto()
{
CategoryId = item.CategoryId,
CategoryName = item.Category == null ? null : item.Category.Name,
ProductId = item.ProductId,
Id = item.Id
});
i++;
}
return result;
}
private static List<StorageFileSDto> funcMain16(List<ProductStorageFile> p34, List<StorageFileSDto> p35)
{
if (p34 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(p34.Count);
int i = 0;
int len = p34.Count;
while (i < len)
{
ProductStorageFile item = p34[i];
ProductStorageFile item = p27[i];
result.Add(item == null ? null : new StorageFileSDto()
{
Name = item.Name,

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain;
namespace NetinaShop.Domain;
public class MapsterRegister : IRegister
{

View File

@ -11,8 +11,8 @@ public class ClaimDto : INotifyPropertyChanged
public string Detail { get; set; } = string.Empty;
public bool IsSelected { get; set; } = false;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

View File

@ -1,5 +1,11 @@
namespace NetinaShop.Domain.Models.Settings;
public class ShopSettings
{
public double TaxesFee { get; set; }
public double ServiceFee { get; set; }
public bool ServiceIsPercent { get; set; }
}
public class SiteSettings
{
public JwtSettings JwtSettings { get; set; } = new JwtSettings();

View File

@ -36,8 +36,6 @@
<ItemGroup>
<Folder Include="Dtos\LargDtos\" />
<Folder Include="Dtos\RequestDtos\" />
<Folder Include="Entities\StorageFiles\" />
<Folder Include="Models\Settings\" />
</ItemGroup>
@ -64,6 +62,8 @@
<Using Include="NetinaShop.Common.Models.Entity" />
<Using Include="NetinaShop.Common.Models.Mapper" />
<Using Include="NetinaShop.Domain.Dtos.LargDtos" />
<Using Include="NetinaShop.Domain.Dtos.RequestDtos" />
<Using Include="NetinaShop.Domain.Dtos.ResponseDtos" />
<Using Include="NetinaShop.Domain.Dtos.SmallDtos" />
<Using Include="NetinaShop.Domain.Entities.Blogs" />
<Using Include="NetinaShop.Domain.Entities.Brands" />

View File

@ -0,0 +1,7 @@
namespace NetinaShop.Repository.Abstracts;
public interface IPaymentService : IScopedDependency
{
Task<string> GetPaymentLinkAsync(Guid orderId, double amount, string description);
Task<bool> VerifiedPaymentAsync(string fishNumber, Guid orderId);
}

View File

@ -1,8 +1,4 @@
using NetinaShop.Domain.Entities.Categories;
using NetinaShop.Repository.Repositories.Base;
using NetinaShop.Repository.Repositories.Base.Contracts;
namespace NetinaShop.Repository.Handlers.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class CreateCategoryCommandHandler : IRequestHandler<CreateCategoryCommand,CategoryLDto>
{

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class DeleteCategoryCommandHandler : IRequestHandler<DeleteCategoryCommand, bool>
{

View File

@ -1,8 +1,4 @@
using NetinaShop.Domain.CommandQueries.Queries;
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class GetCategoriesQueryHandler : IRequestHandler<GetCategoriesQuery, List<CategorySDto>>
{

View File

@ -1,9 +1,6 @@
using NetinaShop.Domain.CommandQueries.Queries;
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class GetCategoryQueryHandler : IRequestHandler<GetCategoryQuery, CategoryLDto>>
public class GetCategoryQueryHandler : IRequestHandler<GetCategoryQuery, CategoryLDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;

View File

@ -1,6 +1,4 @@
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class UpdateCategoryCommandHandler : IRequestHandler<UpdateCategoryCommand, bool>
{

View File

@ -0,0 +1,59 @@
namespace NetinaShop.Repository.Handlers.Discounts;
public class CalculateDiscountCommandHandler : IRequestHandler<CalculateDiscountCommand , double>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public CalculateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<double> Handle(CalculateDiscountCommand request, CancellationToken cancellationToken)
{
if (request.Order == null)
throw new AppException("Order is null", ApiResultStatusCode.BadRequest);
var discount = await _repositoryWrapper.SetRepository<Discount>()
.TableNoTracking
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
if (discount == null)
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
double discountPrice = 0;
if (discount.Type == DiscountType.All)
{
var totalPrice = request.Order.OrderProducts.Sum(op => op.ProductCost);
discountPrice = discount.AmountType == DiscountAmountType.Amount
? totalPrice - discount.DiscountAmount
: totalPrice - ((totalPrice / 100) * discount.DiscountAmount);
}
else if (discount.Type == DiscountType.Category)
{
var categoryDiscount = await _repositoryWrapper.SetRepository<CategoryDiscount>()
.TableNoTracking
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
var totalPrice = request.Order.OrderProducts.Where(op=>op.ProductCategoryId == categoryDiscount!.CategoryId).Sum(op => op.ProductCost);
discountPrice = discount.AmountType == DiscountAmountType.Amount
? totalPrice - discount.DiscountAmount
: totalPrice - ((totalPrice / 100) * discount.DiscountAmount);
}
else if (discount.Type == DiscountType.Product)
{
var productDiscount = await _repositoryWrapper.SetRepository<ProductDiscount>()
.TableNoTracking
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
var totalPrice = request.Order.OrderProducts.Where(op => op.ProductId == productDiscount!.ProductId).Sum(op => op.ProductCost);
discountPrice = discount.AmountType == DiscountAmountType.Amount
? totalPrice - discount.DiscountAmount
: totalPrice - ((totalPrice / 100) * discount.DiscountAmount);
}
else if (discount.Type == DiscountType.Subscriber)
{
throw new NotImplementedException("Subscribe discount not implemented");
}
return discountPrice;
}
}

View File

@ -1,6 +1,4 @@
using NetinaShop.Repository.Repositories.Base;
namespace NetinaShop.Repository.Handlers.Discounts;
namespace NetinaShop.Repository.Handlers.Discounts;
public class CreateDiscountCommandHandler : IRequestHandler<CreateDiscountCommand , DiscountLDto>
{

View File

@ -0,0 +1,45 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.OrderBags;
public class AddToOrderBagCommandHandler : IRequestHandler<AddToOrderBagCommand,bool>
{
private readonly IMediator _mediator;
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
public AddToOrderBagCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService)
{
_mediator = mediator;
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
}
public async Task<bool> Handle(AddToOrderBagCommand 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 product = await _repositoryWrapper.SetRepository<Product>()
.TableNoTracking
.FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken);
if (product == null)
throw new AppException("Product not found ",ApiResultStatusCode.NotFound);
if (!product.IsEnable)
throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest);
var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken);
orderBag.AddToOrderBag(product, request.Count);
_repositoryWrapper.SetRepository<Order>().Update(orderBag);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
await _mediator.Send(new CalculateOrderCommand(orderBag.Id), cancellationToken);
return true;
}
}

View File

@ -0,0 +1,42 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.OrderBags;
public class GetUserOrderBagQueryHandler : IRequestHandler<GetUserOrderBagQuery,Order>
{
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
private readonly IMediator _mediator;
public GetUserOrderBagQueryHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService,IMediator mediator)
{
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
_mediator = mediator;
}
public async Task<Order> Handle(GetUserOrderBagQuery 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 order = await _repositoryWrapper.SetRepository<Order>()
.TableNoTracking
.FirstOrDefaultAsync(o => o.UserId == userId && o.OrderStatus == OrderStatus.OrderBag,cancellationToken);
if (order == null)
order = await _mediator.Send(new CreateBaseOrderCommand(userId),cancellationToken);
else
{
var orderProducts = await _repositoryWrapper.SetRepository<OrderProduct>()
.TableNoTracking
.Where(op=>op.OrderId==order.Id)
.ToListAsync(cancellationToken);
orderProducts.ForEach(op=>order.AddOrderProduct(op));
}
return order;
}
}

View File

@ -0,0 +1,44 @@
using Order = NetinaShop.Domain.Entities.Orders.Order;
namespace NetinaShop.Repository.Handlers.OrderBags;
public class RemoveFromOrderBagCommandHandler : IRequestHandler<RemoveFromOrderBagCommand,bool>
{
private readonly ICurrentUserService _currentUserService;
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly IMediator _mediator;
public RemoveFromOrderBagCommandHandler(ICurrentUserService currentUserService, IRepositoryWrapper repositoryWrapper,IMediator mediator)
{
_currentUserService = currentUserService;
_repositoryWrapper = repositoryWrapper;
_mediator = mediator;
}
public async Task<bool> Handle(RemoveFromOrderBagCommand 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 product = await _repositoryWrapper.SetRepository<Product>()
.TableNoTracking
.FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken);
if (product == null)
throw new AppException("Product not found ", ApiResultStatusCode.NotFound);
if (!product.IsEnable)
throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest);
var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken);
orderBag.RemoveFromOrderBag(product, request.Count);
_repositoryWrapper.SetRepository<Order>().Update(orderBag);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
await _mediator.Send(new CalculateOrderCommand(orderBag.Id), cancellationToken);
return true;
}
}

View File

@ -0,0 +1,29 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.OrderBags;
public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountCommand,bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly IMediator _mediator;
public SubmitDiscountCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator)
{
_repositoryWrapper = repositoryWrapper;
_mediator = mediator;
}
public async Task<bool> Handle(SubmitDiscountCommand request, CancellationToken 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);
order.SetDiscount(request.DiscountCode);
_repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
return true;
}
}

View File

@ -0,0 +1,38 @@
using NetinaShop.Domain.Entities.Orders;
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.OrderBags;
public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeliveryCommand,bool>
{
private readonly IMediator _mediator;
private readonly IRepositoryWrapper _repositoryWrapper;
public SubmitOrderDeliveryCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper)
{
_mediator = mediator;
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken)
{
var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken);
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);
_repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
return true;
}
}

View File

@ -0,0 +1,51 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.OrderBags;
public class SubmitOrderPaymentCommandHandler : IRequestHandler<SubmitOrderPaymentCommand , SubmitOrderPaymentResponseDto>
{
private readonly IMediator _mediator;
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly IPaymentService _paymentService;
public SubmitOrderPaymentCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper, IPaymentService paymentService)
{
_mediator = mediator;
_repositoryWrapper = repositoryWrapper;
_paymentService = paymentService;
}
public async Task<SubmitOrderPaymentResponseDto> Handle(SubmitOrderPaymentCommand request, CancellationToken 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 response = new SubmitOrderPaymentResponseDto();
if (request.PaymentMethod == OrderPaymentMethod.OnlinePayment)
{
response.NeedToPayOnline = true;
response.PaymentUrl = await _paymentService.GetPaymentLinkAsync(order.Id, order.TotalPrice, $"پرداخت سفارش {order.Id}");
}
else if (request.PaymentMethod == OrderPaymentMethod.Cash)
{
response.NeedToPayOnline = false;
order.SetSubmitOrder(request.PaymentMethod);
_repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
else if (request.PaymentMethod == OrderPaymentMethod.CardTransfer)
{
response.NeedToPayOnline = false;
order.SetSubmitOrder(request.PaymentMethod);
_repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
return response;
}
}

View File

@ -0,0 +1,43 @@
using Microsoft.IdentityModel.Tokens;
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.Orders;
public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderCommand,Order>
{
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly IMediator _mediator;
private readonly ShopSettings _shopSettings;
public CalculateOrderCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator,IOptionsSnapshot<ShopSettings> snapshot)
{
_repositoryWrapper = repositoryWrapper;
_mediator = mediator;
_shopSettings = snapshot.Value;
}
public async Task<Order> Handle(CalculateOrderCommand request, CancellationToken cancellationToken)
{
var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken);
if (order.OrderStatus != OrderStatus.OrderBag)
throw new AppException("Order is not in bag status and cant be calculate", ApiResultStatusCode.BadRequest);
var totalProductPrice = order.OrderProducts.Sum(op => op.ProductCost);
var totalPackingPrice = order.OrderProducts.Sum(op => op.PackingCost);
var servicePrice = _shopSettings.ServiceIsPercent
? (totalProductPrice / 100) * _shopSettings.ServiceFee
: _shopSettings.ServiceFee;
var deliveryPrice = order.OrderDeliveries.Sum(op => op.DeliveryCost);
double discountPrice = 0;
if (!order.DiscountCode.IsNullOrEmpty())
{
discountPrice = await _mediator.Send(new CalculateDiscountCommand(order.DiscountCode, order),cancellationToken);
}
var taxesPrice = (((totalProductPrice - discountPrice) + totalPackingPrice + servicePrice) / 100) * _shopSettings.TaxesFee;
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice);
_repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return order;
}
}

View File

@ -0,0 +1,27 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.Orders;
public class CreateBaseOrderCommandHandler : IRequestHandler<CreateBaseOrderCommand,Order>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public CreateBaseOrderCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<Order> Handle(CreateBaseOrderCommand request, CancellationToken cancellationToken)
{
if (request.UserId == default)
throw new AppException("User id is null");
var order = Order.Create(request.UserId);
_repositoryWrapper.SetRepository<Order>()
.Add(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return order;
}
}

View File

@ -0,0 +1,24 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.Orders;
public class DeleteOrderCommandHandler : IRequestHandler<DeleteOrderCommand,bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public DeleteOrderCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(DeleteOrderCommand request, CancellationToken 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);
_repositoryWrapper.SetRepository<Order>().Delete(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,38 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.Orders;
public class GetOrderQueryHandler : IRequestHandler<GetOrderQuery, Order>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetOrderQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<Order> Handle(GetOrderQuery request, CancellationToken cancellationToken)
{
var order = await _repositoryWrapper.SetRepository<Order>()
.TableNoTracking
.FirstOrDefaultAsync(o => o.Id == request.Id, cancellationToken);
if (order == null)
throw new AppException("Order not found", ApiResultStatusCode.NotFound);
var orderProducts = await _repositoryWrapper.SetRepository<OrderProduct>()
.TableNoTracking
.Where(op => op.OrderId == order.Id)
.ToListAsync(cancellationToken);
orderProducts.ForEach(op => order.AddOrderProduct(op));
var orderDeliveries = 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));
return order;
}
}

View File

@ -0,0 +1,23 @@
using NetinaShop.Domain.Entities.Orders;
namespace NetinaShop.Repository.Handlers.Orders;
public class GetOrdersQueryHandler : IRequestHandler<GetOrdersQuery,List<OrderSDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetOrdersQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public Task<List<OrderSDto>> Handle(GetOrdersQuery request, CancellationToken cancellationToken)
{
return _repositoryWrapper.SetRepository<Order>()
.TableNoTracking
.Skip(request.Page * 15)
.Take(15)
.Select(OrderMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
}
}

View File

@ -12,18 +12,13 @@ public class CreateProductCommandHandler : IRequestHandler<CreateProductCommand,
public async Task<ProductLDto> Handle(CreateProductCommand request, CancellationToken cancellationToken)
{
var ent = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck,
request.Tags, request.Warranty, request.BrandId);
request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost, request.BrandId,request.CategoryId);
foreach (var specification in request.Specifications)
{
ent.AddSpecification(specification.Title, specification.Detail, specification.Value,
specification.IsFeature, specification.ParentId);
}
foreach (var category in request.Categories)
{
ent.AddCategory(category);
}
foreach (var file in request.Files)
{
ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType);

View File

@ -1,6 +1,4 @@
using NetinaShop.Repository.Repositories.Base;
namespace NetinaShop.Repository.Handlers.Products;
namespace NetinaShop.Repository.Handlers.Products;
public class DeleteProductCommandHandler : IRequestHandler<DeleteProductCommand, bool>
{

View File

@ -16,7 +16,7 @@ public class UpdateProductCommandHandler : IRequestHandler<UpdateProductCommand,
throw new AppException("Product not found", ApiResultStatusCode.NotFound);
var newEnt = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck,
request.Tags, request.Warranty, request.BrandId);
request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost, request.BrandId,request.CategoryId);
newEnt.Id = ent.Id;
var dbSpecifications = await _repositoryWrapper.SetRepository<Specification>().TableNoTracking
@ -35,23 +35,6 @@ public class UpdateProductCommandHandler : IRequestHandler<UpdateProductCommand,
}
var dbCats = await _repositoryWrapper.SetRepository<ProductCategory>().TableNoTracking
.Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken);
foreach (var dbCat in dbCats)
{
if (request.Categories.Any(s => s == dbCat.CategoryId))
{
_repositoryWrapper.SetRepository<ProductCategory>().Delete(dbCat);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
}
foreach (var category in request.Categories)
{
if (dbCats.Any(c => c.Id == category))
newEnt.AddCategory(category);
}
var dbFiles = await _repositoryWrapper.SetRepository<ProductStorageFile>().TableNoTracking
.Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken);

View File

@ -1,5 +1,4 @@
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Warehouses;
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.Warehouses;
@ -14,7 +13,7 @@ public class CreateShippingCommandHandler : IRequestHandler<CreateShippingComman
public async Task<ShippingSDto> Handle(CreateShippingCommand request, CancellationToken cancellationToken)
{
var ent = Shipping.Create(request.Title, request.WarehouseName, request.IsFastShipping, request.IsShipBySeller,
request.IsOriginalWarehouse);
request.IsOriginalWarehouse,request.DeliveryCost);
_repositoryWrapper.SetRepository<Shipping>().Add(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.AdaptToSDto();

View File

@ -0,0 +1,22 @@
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.Warehouses;
public class GetShippingQueryHandler : IRequestHandler<GetShippingQuery, ShippingSDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetShippingQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<ShippingSDto> Handle(GetShippingQuery request, CancellationToken cancellationToken)
{
var shippingMethod = await _repositoryWrapper.SetRepository<Shipping>().TableNoTracking.Where(b => b.Id == request.Id)
.Select(ShippingMapper.ProjectToSDto)
.FirstOrDefaultAsync(cancellationToken);
if (shippingMethod == null)
throw new AppException("Shipping method not found", ApiResultStatusCode.NotFound);
return shippingMethod;
}
}

View File

@ -0,0 +1,23 @@
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.Warehouses;
public class GetShippingsQueryHandler : IRequestHandler<GetShippingsQuery,List<ShippingSDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetShippingsQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<ShippingSDto>> Handle(GetShippingsQuery request, CancellationToken cancellationToken)
{
return await _repositoryWrapper
.SetRepository<Shipping>()
.TableNoTracking.OrderByDescending(b => b.CreatedAt)
.Skip(request.Page * 10)
.Take(10)
.Select(ShippingMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
}
}

View File

@ -18,7 +18,7 @@ public class UpdateShippingCommandHandler : IRequestHandler<UpdateShippingComman
throw new AppException("Shipping not found", ApiResultStatusCode.NotFound);
var newEnt = Shipping.Create(request.Title, request.WarehouseName, request.IsFastShipping, request.IsShipBySeller,
request.IsOriginalWarehouse);
request.IsOriginalWarehouse,request.DeliveryCost);
newEnt.Id = ent.Id;
_repositoryWrapper.SetRepository<Shipping>().Update(newEnt);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);

View File

@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace NetinaShop.Repository.Migrations
{
[DbContext(typeof(ApplicationContext))]
[Migration("20231211073413_init")]
partial class init
[Migration("20231231111356_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -146,7 +146,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -159,7 +158,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ReadingTime")
@ -169,7 +167,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summery")
@ -201,7 +198,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -215,7 +211,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -226,7 +221,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -244,7 +238,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -261,7 +254,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -276,7 +268,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -294,7 +285,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -308,7 +298,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -322,7 +311,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -352,7 +340,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("DiscountAmount")
@ -391,7 +378,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("PriceCeiling")
@ -404,7 +390,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
@ -435,11 +420,10 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("DeliveryPrice")
.HasColumnType("bigint");
b.Property<double>("DeliveryPrice")
.HasColumnType("double precision");
b.Property<string>("DiscountCode")
.IsRequired()
@ -448,8 +432,8 @@ namespace NetinaShop.Repository.Migrations
b.Property<Guid?>("DiscountId")
.HasColumnType("uuid");
b.Property<long>("DiscountPrice")
.HasColumnType("bigint");
b.Property<double>("DiscountPrice")
.HasColumnType("double precision");
b.Property<DateTime>("DoneAt")
.HasColumnType("timestamp without time zone");
@ -464,7 +448,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("OrderAt")
@ -473,8 +456,14 @@ namespace NetinaShop.Repository.Migrations
b.Property<int>("OrderStatus")
.HasColumnType("integer");
b.Property<long>("PackingPrice")
.HasColumnType("bigint");
b.Property<double>("PackingPrice")
.HasColumnType("double precision");
b.Property<DateTime>("PayedAt")
.HasColumnType("timestamp without time zone");
b.Property<int>("PaymentMethod")
.HasColumnType("integer");
b.Property<int>("PreparingMinute")
.HasColumnType("integer");
@ -483,25 +472,29 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("ServicePrice")
.HasColumnType("bigint");
b.Property<double>("ServicePrice")
.HasColumnType("double precision");
b.Property<long>("TaxesPrice")
.HasColumnType("bigint");
b.Property<double>("TaxesPrice")
.HasColumnType("double precision");
b.Property<long>("TotalPrice")
.HasColumnType("bigint");
b.Property<double>("TotalPrice")
.HasColumnType("double precision");
b.Property<long>("TotalProductsPrice")
.HasColumnType("bigint");
b.Property<double>("TotalProductsPrice")
.HasColumnType("double precision");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DiscountId");
b.HasIndex("UserId");
b.ToTable("Orders", "public");
});
@ -519,9 +512,11 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DeliveryCost")
.HasColumnType("double precision");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
@ -529,7 +524,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("OrderId")
@ -551,13 +545,17 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShippingId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ShippingId");
b.ToTable("OrderDeliveries", "public");
});
@ -574,7 +572,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -584,7 +581,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("OrderId")
@ -593,11 +589,20 @@ namespace NetinaShop.Repository.Migrations
b.Property<int>("OrderProductStatus")
.HasColumnType("integer");
b.Property<float>("ProductCost")
.HasColumnType("real");
b.Property<double>("PackingCost")
.HasColumnType("double precision");
b.Property<float>("ProductFee")
.HasColumnType("real");
b.Property<double>("PackingFee")
.HasColumnType("double precision");
b.Property<Guid>("ProductCategoryId")
.HasColumnType("uuid");
b.Property<double>("ProductCost")
.HasColumnType("double precision");
b.Property<double>("ProductFee")
.HasColumnType("double precision");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
@ -606,7 +611,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -624,14 +628,22 @@ namespace NetinaShop.Repository.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("BeDisplayed")
.HasColumnType("boolean");
b.Property<Guid>("BrandId")
.HasColumnType("uuid");
b.Property<Guid>("CategoryId")
.HasColumnType("uuid");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
@ -642,6 +654,9 @@ namespace NetinaShop.Repository.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsEnable")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
@ -649,9 +664,11 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PackingCost")
.HasColumnType("double precision");
b.Property<string>("PersianName")
.IsRequired()
.HasColumnType("text");
@ -660,7 +677,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summery")
@ -679,52 +695,9 @@ namespace NetinaShop.Repository.Migrations
b.HasIndex("BrandId");
b.ToTable("Products", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CategoryId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.HasIndex("ProductId");
b.ToTable("ProductCategories", "public");
b.ToTable("Products", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b =>
@ -741,7 +714,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsBuyer")
@ -754,7 +726,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
@ -767,7 +738,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
@ -796,7 +766,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
@ -813,7 +782,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ParentId")
@ -826,13 +794,16 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentId");
@ -842,58 +813,6 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("Specifications", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Sellers.Shipping", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFastShipping")
.HasColumnType("boolean");
b.Property<bool>("IsOriginalWarehouse")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsShipBySeller")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Shippings", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b =>
{
b.Property<Guid>("Id")
@ -904,7 +823,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Discriminator")
@ -936,7 +854,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -947,7 +864,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -1098,7 +1014,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -1114,7 +1029,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PostalCode")
@ -1133,7 +1047,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -1156,7 +1069,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -1166,7 +1078,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
@ -1176,7 +1087,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -1191,6 +1101,58 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("UserFavoriteProducts", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.HasColumnType("text");
b.Property<double>("DeliveryCost")
.HasColumnType("double precision");
b.Property<bool>("IsFastShipping")
.HasColumnType("boolean");
b.Property<bool>("IsOriginalWarehouse")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsShipBySeller")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Shippings", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b =>
{
b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount");
@ -1341,17 +1303,33 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null)
.WithMany("Orders")
.HasForeignKey("DiscountId");
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b =>
{
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
.WithMany()
.WithMany("OrderDeliveries")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping")
.WithMany()
.HasForeignKey("ShippingId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Order");
b.Navigation("Shipping");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b =>
@ -1381,26 +1359,15 @@ namespace NetinaShop.Repository.Migrations
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Brand");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b =>
{
b.HasOne("NetinaShop.Domain.Entities.Categories.Category", "Category")
.WithMany("Products")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany("Categories")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Brand");
b.Navigation("Category");
b.Navigation("Product");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b =>
@ -1570,13 +1537,13 @@ namespace NetinaShop.Repository.Migrations
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b =>
{
b.Navigation("OrderDeliveries");
b.Navigation("OrderProducts");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b =>
{
b.Navigation("Categories");
b.Navigation("Files");
b.Navigation("OrderProducts");

View File

@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class init : Migration
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -25,11 +25,11 @@ namespace NetinaShop.Repository.Migrations
Description = table.Column<string>(type: "text", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -48,11 +48,11 @@ namespace NetinaShop.Repository.Migrations
PageUrl = table.Column<string>(type: "text", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -70,11 +70,11 @@ namespace NetinaShop.Repository.Migrations
ParentId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -117,13 +117,14 @@ namespace NetinaShop.Repository.Migrations
IsFastShipping = table.Column<bool>(type: "boolean", nullable: false),
IsShipBySeller = table.Column<bool>(type: "boolean", nullable: false),
IsOriginalWarehouse = table.Column<bool>(type: "boolean", nullable: false),
DeliveryCost = table.Column<double>(type: "double precision", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -177,11 +178,11 @@ namespace NetinaShop.Repository.Migrations
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -207,14 +208,19 @@ namespace NetinaShop.Repository.Migrations
ExpertCheck = table.Column<string>(type: "text", nullable: false),
Tags = table.Column<string>(type: "text", nullable: false),
Warranty = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false),
IsEnable = table.Column<bool>(type: "boolean", nullable: false),
BeDisplayed = table.Column<bool>(type: "boolean", nullable: false),
PackingCost = table.Column<double>(type: "double precision", nullable: false),
BrandId = table.Column<Guid>(type: "uuid", nullable: false),
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -226,6 +232,13 @@ namespace NetinaShop.Repository.Migrations
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Products_Categories_CategoryId",
column: x => x.CategoryId,
principalSchema: "public",
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -333,11 +346,11 @@ namespace NetinaShop.Repository.Migrations
UserId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -405,11 +418,11 @@ namespace NetinaShop.Repository.Migrations
ProductId = table.Column<Guid>(type: "uuid", nullable: true),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -430,41 +443,6 @@ namespace NetinaShop.Repository.Migrations
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ProductCategories",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductCategories", x => x.Id);
table.ForeignKey(
name: "FK_ProductCategories_Categories_CategoryId",
column: x => x.CategoryId,
principalSchema: "public",
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ProductCategories_Products_ProductId",
column: x => x.ProductId,
principalSchema: "public",
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Reviews",
schema: "public",
@ -479,11 +457,11 @@ namespace NetinaShop.Repository.Migrations
UserId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -512,16 +490,17 @@ namespace NetinaShop.Repository.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Detail = table.Column<string>(type: "text", nullable: false),
Value = table.Column<string>(type: "text", nullable: false),
IsFeature = table.Column<bool>(type: "boolean", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
ParentId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -561,11 +540,11 @@ namespace NetinaShop.Repository.Migrations
ProductId = table.Column<Guid>(type: "uuid", nullable: true),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -610,11 +589,11 @@ namespace NetinaShop.Repository.Migrations
UserId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -641,27 +620,30 @@ namespace NetinaShop.Repository.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TotalPrice = table.Column<long>(type: "bigint", nullable: false),
DeliveryPrice = table.Column<long>(type: "bigint", nullable: false),
TaxesPrice = table.Column<long>(type: "bigint", nullable: false),
ServicePrice = table.Column<long>(type: "bigint", nullable: false),
PackingPrice = table.Column<long>(type: "bigint", nullable: false),
TotalProductsPrice = table.Column<long>(type: "bigint", nullable: false),
DiscountPrice = table.Column<long>(type: "bigint", nullable: false),
TotalProductsPrice = table.Column<double>(type: "double precision", nullable: false),
PackingPrice = table.Column<double>(type: "double precision", nullable: false),
ServicePrice = table.Column<double>(type: "double precision", nullable: false),
DeliveryPrice = table.Column<double>(type: "double precision", nullable: false),
DiscountPrice = table.Column<double>(type: "double precision", nullable: false),
TaxesPrice = table.Column<double>(type: "double precision", nullable: false),
TotalPrice = table.Column<double>(type: "double precision", nullable: false),
IsPayed = table.Column<bool>(type: "boolean", nullable: false),
PayedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
PaymentMethod = table.Column<int>(type: "integer", nullable: false),
OrderStatus = table.Column<int>(type: "integer", nullable: false),
DoneAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
OrderAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
PreparingMinute = table.Column<int>(type: "integer", nullable: false),
DiscountCode = table.Column<string>(type: "text", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
DiscountId = table.Column<Guid>(type: "uuid", nullable: true),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -672,6 +654,13 @@ namespace NetinaShop.Repository.Migrations
principalSchema: "public",
principalTable: "Discounts",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Orders_Users_UserId",
column: x => x.UserId,
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -684,14 +673,16 @@ namespace NetinaShop.Repository.Migrations
PostalCode = table.Column<string>(type: "text", nullable: false),
ReceiverPhoneNumber = table.Column<string>(type: "text", nullable: false),
ReceiverFullName = table.Column<string>(type: "text", nullable: false),
DeliveryCost = table.Column<double>(type: "double precision", nullable: false),
ShippingId = table.Column<Guid>(type: "uuid", nullable: false),
OrderId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -703,6 +694,13 @@ namespace NetinaShop.Repository.Migrations
principalTable: "Orders",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_OrderDeliveries_Shippings_ShippingId",
column: x => x.ShippingId,
principalSchema: "public",
principalTable: "Shippings",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -712,18 +710,21 @@ namespace NetinaShop.Repository.Migrations
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false),
ProductFee = table.Column<float>(type: "real", nullable: false),
ProductCost = table.Column<float>(type: "real", nullable: false),
ProductFee = table.Column<double>(type: "double precision", nullable: false),
ProductCost = table.Column<double>(type: "double precision", nullable: false),
PackingFee = table.Column<double>(type: "double precision", nullable: false),
PackingCost = table.Column<double>(type: "double precision", nullable: false),
OrderProductStatus = table.Column<int>(type: "integer", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
ProductCategoryId = table.Column<Guid>(type: "uuid", nullable: false),
OrderId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: true),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: true),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
ModifiedBy = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
@ -786,6 +787,12 @@ namespace NetinaShop.Repository.Migrations
table: "OrderDeliveries",
column: "OrderId");
migrationBuilder.CreateIndex(
name: "IX_OrderDeliveries_ShippingId",
schema: "public",
table: "OrderDeliveries",
column: "ShippingId");
migrationBuilder.CreateIndex(
name: "IX_OrderProducts_OrderId",
schema: "public",
@ -805,16 +812,10 @@ namespace NetinaShop.Repository.Migrations
column: "DiscountId");
migrationBuilder.CreateIndex(
name: "IX_ProductCategories_CategoryId",
name: "IX_Orders_UserId",
schema: "public",
table: "ProductCategories",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_ProductCategories_ProductId",
schema: "public",
table: "ProductCategories",
column: "ProductId");
table: "Orders",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Products_BrandId",
@ -822,6 +823,12 @@ namespace NetinaShop.Repository.Migrations
table: "Products",
column: "BrandId");
migrationBuilder.CreateIndex(
name: "IX_Products_CategoryId",
schema: "public",
table: "Products",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_Reviews_ProductId",
schema: "public",
@ -940,10 +947,6 @@ namespace NetinaShop.Repository.Migrations
name: "OrderProducts",
schema: "public");
migrationBuilder.DropTable(
name: "ProductCategories",
schema: "public");
migrationBuilder.DropTable(
name: "Reviews",
schema: "public");
@ -952,10 +955,6 @@ namespace NetinaShop.Repository.Migrations
name: "RoleClaims",
schema: "public");
migrationBuilder.DropTable(
name: "Shippings",
schema: "public");
migrationBuilder.DropTable(
name: "Specifications",
schema: "public");
@ -980,6 +979,10 @@ namespace NetinaShop.Repository.Migrations
name: "UserRoles",
schema: "public");
migrationBuilder.DropTable(
name: "Shippings",
schema: "public");
migrationBuilder.DropTable(
name: "Orders",
schema: "public");
@ -992,20 +995,16 @@ namespace NetinaShop.Repository.Migrations
name: "Roles",
schema: "public");
migrationBuilder.DropTable(
name: "Users",
schema: "public");
migrationBuilder.DropTable(
name: "Discounts",
schema: "public");
migrationBuilder.DropTable(
name: "BlogCategories",
name: "Users",
schema: "public");
migrationBuilder.DropTable(
name: "Categories",
name: "BlogCategories",
schema: "public");
migrationBuilder.DropTable(
@ -1015,6 +1014,10 @@ namespace NetinaShop.Repository.Migrations
migrationBuilder.DropTable(
name: "Brands",
schema: "public");
migrationBuilder.DropTable(
name: "Categories",
schema: "public");
}
}
}

View File

@ -143,7 +143,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -156,7 +155,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ReadingTime")
@ -166,7 +164,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summery")
@ -198,7 +195,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -212,7 +208,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -223,7 +218,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -241,7 +235,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -258,7 +251,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -273,7 +265,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -291,7 +282,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
@ -305,7 +295,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -319,7 +308,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -349,7 +337,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("DiscountAmount")
@ -388,7 +375,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("PriceCeiling")
@ -401,7 +387,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("StartDate")
@ -432,11 +417,10 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("DeliveryPrice")
.HasColumnType("bigint");
b.Property<double>("DeliveryPrice")
.HasColumnType("double precision");
b.Property<string>("DiscountCode")
.IsRequired()
@ -445,8 +429,8 @@ namespace NetinaShop.Repository.Migrations
b.Property<Guid?>("DiscountId")
.HasColumnType("uuid");
b.Property<long>("DiscountPrice")
.HasColumnType("bigint");
b.Property<double>("DiscountPrice")
.HasColumnType("double precision");
b.Property<DateTime>("DoneAt")
.HasColumnType("timestamp without time zone");
@ -461,7 +445,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("OrderAt")
@ -470,8 +453,14 @@ namespace NetinaShop.Repository.Migrations
b.Property<int>("OrderStatus")
.HasColumnType("integer");
b.Property<long>("PackingPrice")
.HasColumnType("bigint");
b.Property<double>("PackingPrice")
.HasColumnType("double precision");
b.Property<DateTime>("PayedAt")
.HasColumnType("timestamp without time zone");
b.Property<int>("PaymentMethod")
.HasColumnType("integer");
b.Property<int>("PreparingMinute")
.HasColumnType("integer");
@ -480,25 +469,29 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<long>("ServicePrice")
.HasColumnType("bigint");
b.Property<double>("ServicePrice")
.HasColumnType("double precision");
b.Property<long>("TaxesPrice")
.HasColumnType("bigint");
b.Property<double>("TaxesPrice")
.HasColumnType("double precision");
b.Property<long>("TotalPrice")
.HasColumnType("bigint");
b.Property<double>("TotalPrice")
.HasColumnType("double precision");
b.Property<long>("TotalProductsPrice")
.HasColumnType("bigint");
b.Property<double>("TotalProductsPrice")
.HasColumnType("double precision");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("DiscountId");
b.HasIndex("UserId");
b.ToTable("Orders", "public");
});
@ -516,9 +509,11 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DeliveryCost")
.HasColumnType("double precision");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
@ -526,7 +521,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("OrderId")
@ -548,13 +542,17 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ShippingId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ShippingId");
b.ToTable("OrderDeliveries", "public");
});
@ -571,7 +569,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -581,7 +578,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("OrderId")
@ -590,11 +586,20 @@ namespace NetinaShop.Repository.Migrations
b.Property<int>("OrderProductStatus")
.HasColumnType("integer");
b.Property<float>("ProductCost")
.HasColumnType("real");
b.Property<double>("PackingCost")
.HasColumnType("double precision");
b.Property<float>("ProductFee")
.HasColumnType("real");
b.Property<double>("PackingFee")
.HasColumnType("double precision");
b.Property<Guid>("ProductCategoryId")
.HasColumnType("uuid");
b.Property<double>("ProductCost")
.HasColumnType("double precision");
b.Property<double>("ProductFee")
.HasColumnType("double precision");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
@ -603,7 +608,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -621,14 +625,22 @@ namespace NetinaShop.Repository.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<bool>("BeDisplayed")
.HasColumnType("boolean");
b.Property<Guid>("BrandId")
.HasColumnType("uuid");
b.Property<Guid>("CategoryId")
.HasColumnType("uuid");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
@ -639,6 +651,9 @@ namespace NetinaShop.Repository.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsEnable")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
@ -646,9 +661,11 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PackingCost")
.HasColumnType("double precision");
b.Property<string>("PersianName")
.IsRequired()
.HasColumnType("text");
@ -657,7 +674,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summery")
@ -676,52 +692,9 @@ namespace NetinaShop.Repository.Migrations
b.HasIndex("BrandId");
b.ToTable("Products", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CategoryId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CategoryId");
b.HasIndex("ProductId");
b.ToTable("ProductCategories", "public");
b.ToTable("Products", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b =>
@ -738,7 +711,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsBuyer")
@ -751,7 +723,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
@ -764,7 +735,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
@ -793,7 +763,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
@ -810,7 +779,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ParentId")
@ -823,13 +791,16 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ParentId");
@ -839,58 +810,6 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("Specifications", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Sellers.Shipping", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsFastShipping")
.HasColumnType("boolean");
b.Property<bool>("IsOriginalWarehouse")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsShipBySeller")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Shippings", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b =>
{
b.Property<Guid>("Id")
@ -901,7 +820,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Discriminator")
@ -933,7 +851,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
@ -944,7 +861,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@ -1095,7 +1011,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -1111,7 +1026,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PostalCode")
@ -1130,7 +1044,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -1153,7 +1066,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
@ -1163,7 +1075,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
@ -1173,7 +1084,6 @@ namespace NetinaShop.Repository.Migrations
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
@ -1188,6 +1098,58 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("UserFavoriteProducts", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.HasColumnType("text");
b.Property<double>("DeliveryCost")
.HasColumnType("double precision");
b.Property<bool>("IsFastShipping")
.HasColumnType("boolean");
b.Property<bool>("IsOriginalWarehouse")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsShipBySeller")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<string>("WarehouseName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Shippings", "public");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b =>
{
b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount");
@ -1338,17 +1300,33 @@ namespace NetinaShop.Repository.Migrations
b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null)
.WithMany("Orders")
.HasForeignKey("DiscountId");
b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b =>
{
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
.WithMany()
.WithMany("OrderDeliveries")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping")
.WithMany()
.HasForeignKey("ShippingId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Order");
b.Navigation("Shipping");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b =>
@ -1378,26 +1356,15 @@ namespace NetinaShop.Repository.Migrations
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Brand");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b =>
{
b.HasOne("NetinaShop.Domain.Entities.Categories.Category", "Category")
.WithMany("Products")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product")
.WithMany("Categories")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Brand");
b.Navigation("Category");
b.Navigation("Product");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b =>
@ -1567,13 +1534,13 @@ namespace NetinaShop.Repository.Migrations
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b =>
{
b.Navigation("OrderDeliveries");
b.Navigation("OrderProducts");
});
modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b =>
{
b.Navigation("Categories");
b.Navigation("Files");
b.Navigation("OrderProducts");

View File

@ -60,6 +60,7 @@
<Using Include="NetinaShop.Domain.CommandQueries.Commands" />
<Using Include="NetinaShop.Domain.CommandQueries.Queries" />
<Using Include="NetinaShop.Domain.Dtos.LargDtos" />
<Using Include="NetinaShop.Domain.Dtos.ResponseDtos" />
<Using Include="NetinaShop.Domain.Dtos.SmallDtos" />
<Using Include="NetinaShop.Domain.Entities.Categories" />
<Using Include="NetinaShop.Domain.Entities.Discounts" />

View File

@ -7,7 +7,7 @@
{
}
public void Dispose()
public new void Dispose()
{
DbContext?.Dispose();
}
@ -16,6 +16,8 @@
public virtual T GetById(params object[] ids)
{
var ent = Entities.Find(ids);
if (ent == null)
throw new AppException("Ent not found");
Detach(ent);
return ent;
}
@ -29,8 +31,7 @@
{
AssertExtensions.NotNull(entity, nameof(entity));
var entry = DbContext.Entry(entity);
if (entry != null)
entry.State = EntityState.Detached;
entry.State = EntityState.Detached;
}
public virtual void Attach(T entity)

View File

@ -1,7 +1,4 @@
using NetinaShop.Repository.Repositories.Base;
using System.Threading;
namespace NetinaShop.Repository.Repositories.Entity;
namespace NetinaShop.Repository.Repositories.Entity;
public class DiscountRepository : BaseRepository<Discount>, IDiscountRepository
{

View File

@ -5,15 +5,20 @@ VisualStudioVersion = 17.8.34316.72
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Api", "NetinaShop.Api\NetinaShop.Api.csproj", "{12DD0CD6-93AF-4990-8121-E12A05AA75AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Common", "NetinaShop.Common\NetinaShop.Common.csproj", "{53171FE6-AE59-4696-9A8B-FF7CCBF921CB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Common", "NetinaShop.Common\NetinaShop.Common.csproj", "{53171FE6-AE59-4696-9A8B-FF7CCBF921CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Domain", "NetinaShop.Domain\NetinaShop.Domain.csproj", "{A6890803-432B-4045-AF5A-DC5C0B9F8D0D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Domain", "NetinaShop.Domain\NetinaShop.Domain.csproj", "{A6890803-432B-4045-AF5A-DC5C0B9F8D0D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Infrastructure", "NetinaShop.Infrastructure\NetinaShop.Infrastructure.csproj", "{A3AB0DD7-5472-4A1C-9CF4-D0F97B926CF8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Infrastructure", "NetinaShop.Infrastructure\NetinaShop.Infrastructure.csproj", "{A3AB0DD7-5472-4A1C-9CF4-D0F97B926CF8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Core", "NetinaShop.Core\NetinaShop.Core.csproj", "{D422399C-A65D-479B-975C-40202E9C16C3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Core", "NetinaShop.Core\NetinaShop.Core.csproj", "{D422399C-A65D-479B-975C-40202E9C16C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Repository", "NetinaShop.Repository\NetinaShop.Repository.csproj", "{4A25936E-275C-41EA-9ADC-4375E8AC5207}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Repository", "NetinaShop.Repository\NetinaShop.Repository.csproj", "{4A25936E-275C-41EA-9ADC-4375E8AC5207}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConfigFiles", "ConfigFiles", "{673BF026-7A2C-4695-9103-79099AACDF73}"
ProjectSection(SolutionItems) = preProject
.version = .version
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution