diff --git a/NetinaShop.Api/Controller/OrderController.cs b/NetinaShop.Api/Controller/OrderController.cs index 6d5bb97..d5514d8 100644 --- a/NetinaShop.Api/Controller/OrderController.cs +++ b/NetinaShop.Api/Controller/OrderController.cs @@ -24,6 +24,9 @@ public class OrderController : ICarterModule group.MapDelete("{id}", DeleteAsync) .WithDisplayName("DeleteOneOrder") .HasApiVersion(1.0); + group.MapGet("{id}/invoice", GetOrderInvoiceAsync) + .WithDisplayName("GetOrderInvoice") + .HasApiVersion(1.0); } @@ -39,6 +42,15 @@ public class OrderController : ICarterModule return TypedResults.Ok(order); } + public async Task DeleteAsync(IMediator mediator, Guid id, CancellationToken cancellationToken = default) => TypedResults.Ok(await mediator.Send(new DeleteOrderCommand(id), cancellationToken)); + + private async Task GetOrderInvoiceAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + { + var file = await mediator.Send(new GetOrderInvoiceCommand(id), cancellationToken); + string fileName = $"Invoice_{id}.pdf"; + return TypedResults.File(file, "application/pdf", fileName); + } + } diff --git a/NetinaShop.Api/Dockerfile b/NetinaShop.Api/Dockerfile index 599a2c4..4528235 100644 --- a/NetinaShop.Api/Dockerfile +++ b/NetinaShop.Api/Dockerfile @@ -2,6 +2,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app + WORKDIR /app EXPOSE 8080 @@ -19,6 +20,11 @@ ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./NetinaShop.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final + + +RUN apt-get update +RUN apt-get install-y libgdiplus + WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "NetinaShop.Api.dll"] \ No newline at end of file diff --git a/NetinaShop.Api/NetinaShop.Api.csproj b/NetinaShop.Api/NetinaShop.Api.csproj index b45486a..3fdee50 100644 --- a/NetinaShop.Api/NetinaShop.Api.csproj +++ b/NetinaShop.Api/NetinaShop.Api.csproj @@ -134,6 +134,7 @@ + diff --git a/NetinaShop.Api/Program.cs b/NetinaShop.Api/Program.cs index 4add805..eb0128a 100644 --- a/NetinaShop.Api/Program.cs +++ b/NetinaShop.Api/Program.cs @@ -1,4 +1,8 @@ +using Autofac.Core; +using DinkToPdf.Contracts; +using DinkToPdf; using NetinaShop.Repository.Behaviors; +using QuestPDF.Infrastructure; var builder = WebApplication.CreateBuilder(args); builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); @@ -40,6 +44,8 @@ builder.Services.AddCustomIdentity(); builder.Services.AddCustomDbContext(configuration); builder.Services.AddMarten(configuration,builder.Environment); builder.Services.AddCarter(); +builder.Services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools())); +QuestPDF.Settings.License = LicenseType.Community; builder.Host.ConfigureContainer(builder => diff --git a/NetinaShop.Api/Views/Invoices/Invoice.cshtml b/NetinaShop.Api/Views/Invoices/Invoice.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/NetinaShop.Api/Views/Invoices/Invoice.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/NetinaShop.Api/wwwroot/fonts/Shabnam-Bold.ttf b/NetinaShop.Api/wwwroot/fonts/Shabnam-Bold.ttf new file mode 100644 index 0000000..dbae563 Binary files /dev/null and b/NetinaShop.Api/wwwroot/fonts/Shabnam-Bold.ttf differ diff --git a/NetinaShop.Api/wwwroot/fonts/Shabnam.ttf b/NetinaShop.Api/wwwroot/fonts/Shabnam.ttf new file mode 100644 index 0000000..7861e3f Binary files /dev/null and b/NetinaShop.Api/wwwroot/fonts/Shabnam.ttf differ diff --git a/NetinaShop.Core/EntityServices/OrderHandlers/GetOrderInvoiceCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderHandlers/GetOrderInvoiceCommandHandler.cs new file mode 100644 index 0000000..cec54e5 --- /dev/null +++ b/NetinaShop.Core/EntityServices/OrderHandlers/GetOrderInvoiceCommandHandler.cs @@ -0,0 +1,128 @@ +using DinkToPdf; +using DinkToPdf.Contracts; +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; +using Unit = QuestPDF.Infrastructure.Unit; + +namespace NetinaShop.Core.EntityServices.OrderHandlers; + +public class GetOrderInvoiceCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; + private readonly IConverter _converter; + + public GetOrderInvoiceCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator,IConverter converter) + { + _repositoryWrapper = repositoryWrapper; + _mediator = mediator; + _converter = converter; + } + public async Task Handle(GetOrderInvoiceCommand request, CancellationToken cancellationToken) + { + var orderLDto = await _mediator.Send(new GetOrderLDtoQuery(request.OrderId), cancellationToken); + + //var textStyleWithFallback = TextStyle + // .Default + // .FontSize(18) + // .Fallback(y => y + // .FontFamily(Fonts.Arial) + // .SemiBold() + // .Underline(false) + // .BackgroundColor(Colors.Red.Lighten4)); + + //var pdf = Document.Create(container => + //{ + // container.Page(page => + // { + // page.Size(PageSizes.A4); + // page.Margin(2,Unit.Centimetre); + // page.PageColor(Colors.White); + // page.DefaultTextStyle(x=>x.FontSize(14)); + + // page.Header() + // .Text(text => + // { + // text.DefaultTextStyle(textStyleWithFallback); + + // text.Line("This is normal text."); + // text.EmptyLine(); + + // text.Line("Following line should use font fallback:"); + // text.Line("中文文本"); + // text.EmptyLine(); + + // text.Line("The following line contains a mix of known and unknown characters."); + // text.Line("Mixed line: This 中文 is 文文 a mixed 本 本 line 本 中文文本!"); + // text.EmptyLine(); + + // text.Span("Emojis work out of the box because of font fallback: 😊😅🥳👍❤😍👌"); + // }); + + // page.Content() + // .ContentFromRightToLeft() + // .Column(x => + // { + // x.Spacing(20); + // x.Item().Text("فاکتور فروش "); + // }); + // }); + //}).GeneratePdf(); + + var sb = new StringBuilder(); + sb.Append(@" + + + + +

فاکتور فروش

+ + + + + + + "); + foreach (var emp in orderLDto.OrderProducts) + { + sb.AppendFormat(@" + + + + + ", emp.ProductName, emp.Count, emp.ProductFee, emp.ProductCost); + } + sb.Append(@" +
NameLastNameAgeGender
{0}{1}{2}{3}
+ + "); + + var globalSettings = new GlobalSettings + { + ColorMode = ColorMode.Color, + Orientation = Orientation.Portrait, + PaperSize = PaperKind.A4, + Margins = new MarginSettings { Top = 10 }, + DocumentTitle = "PDF Report", + Out = @"D:\PDFCreator\Employee_Report.pdf" + }; + var objectSettings = new ObjectSettings + { + PagesCount = true, + HtmlContent = sb.ToString(), + WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "styles.css") }, + HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true }, + FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" } + }; + var pdf = new HtmlToPdfDocument() + { + GlobalSettings = globalSettings, + Objects = { objectSettings } + }; + var file = _converter.Convert(pdf); + + + return file; + } +} \ No newline at end of file diff --git a/NetinaShop.Core/NetinaShop.Core.csproj b/NetinaShop.Core/NetinaShop.Core.csproj index 028f512..2e7cbc1 100644 --- a/NetinaShop.Core/NetinaShop.Core.csproj +++ b/NetinaShop.Core/NetinaShop.Core.csproj @@ -11,9 +11,13 @@ + + + + diff --git a/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs index 5a4718b..836568a 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs @@ -5,4 +5,5 @@ public sealed record CreateBaseOrderCommand(Guid UserId) : IRequest; public sealed record CalculateOrderCommand(Guid OrderId , bool NamoosiCalculate = false) : IRequest; public sealed record ConfirmOrderStepCommand(Guid OrderId , OrderStatus NextOrderStatus) : IRequest; +public sealed record GetOrderInvoiceCommand(Guid OrderId) : IRequest; public sealed record DeleteOrderCommand(Guid OrderId) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs index 461ef24..fcd4adf 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs @@ -27,6 +27,6 @@ public class OrderLDto : BaseDto public List Payments { get; set; } = new(); - public OrderDeliverySDto? OrderDelivery { get; internal set; } + public OrderDeliverySDto OrderDelivery { get; set; } = new(); } diff --git a/NetinaShop.Domain/Mappers/OrderMapper.g.cs b/NetinaShop.Domain/Mappers/OrderMapper.g.cs index 6920deb..ffebf5b 100644 --- a/NetinaShop.Domain/Mappers/OrderMapper.g.cs +++ b/NetinaShop.Domain/Mappers/OrderMapper.g.cs @@ -189,7 +189,15 @@ namespace NetinaShop.Domain.Mappers Payments = funcMain10(p21.Payments), OrderDelivery = p21.OrderDelivery == null ? null : new OrderDeliverySDto() { - Address = p21.OrderDelivery.Address == null ? null : p21.OrderDelivery.Address.ToString(), + Province = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.Province : string.Empty, + City = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.City : string.Empty, + Plaque = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.Plaque : string.Empty, + LocationLat = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.LocationLat : 0f, + LocationLong = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.LocationLong : 0f, + Address = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.Address : string.Empty, + PostalCode = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.PostalCode : string.Empty, + ReceiverPhoneNumber = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.ReceiverPhoneNumber : string.Empty, + ReceiverFullName = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.ReceiverFullName : string.Empty, ShippingMethod = p21.OrderDelivery.Shipping != null ? p21.OrderDelivery.Shipping.Name : string.Empty, DeliveryCost = p21.OrderDelivery.DeliveryCost, AddressId = p21.OrderDelivery.AddressId, @@ -291,7 +299,15 @@ namespace NetinaShop.Domain.Mappers }).ToList(), OrderDelivery = p32.OrderDelivery == null ? null : new OrderDeliverySDto() { - Address = p32.OrderDelivery.Address == null ? null : p32.OrderDelivery.Address.ToString(), + Province = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.Province : string.Empty, + City = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.City : string.Empty, + Plaque = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.Plaque : string.Empty, + LocationLat = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.LocationLat : 0f, + LocationLong = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.LocationLong : 0f, + Address = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.Address : string.Empty, + PostalCode = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.PostalCode : string.Empty, + ReceiverPhoneNumber = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.ReceiverPhoneNumber : string.Empty, + ReceiverFullName = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.ReceiverFullName : string.Empty, ShippingMethod = p32.OrderDelivery.Shipping != null ? p32.OrderDelivery.Shipping.Name : string.Empty, DeliveryCost = p32.OrderDelivery.DeliveryCost, AddressId = p32.OrderDelivery.AddressId, @@ -801,7 +817,15 @@ namespace NetinaShop.Domain.Mappers } OrderDeliverySDto result = p31 ?? new OrderDeliverySDto(); - result.Address = p30.Address == null ? null : p30.Address.ToString(); + result.Province = p30.Address != null ? p30.Address.Province : string.Empty; + result.City = p30.Address != null ? p30.Address.City : string.Empty; + result.Plaque = p30.Address != null ? p30.Address.Plaque : string.Empty; + result.LocationLat = p30.Address != null ? p30.Address.LocationLat : 0f; + result.LocationLong = p30.Address != null ? p30.Address.LocationLong : 0f; + result.Address = p30.Address != null ? p30.Address.Address : string.Empty; + result.PostalCode = p30.Address != null ? p30.Address.PostalCode : string.Empty; + result.ReceiverPhoneNumber = p30.Address != null ? p30.Address.ReceiverPhoneNumber : string.Empty; + result.ReceiverFullName = p30.Address != null ? p30.Address.ReceiverFullName : string.Empty; result.ShippingMethod = p30.Shipping != null ? p30.Shipping.Name : string.Empty; result.DeliveryCost = p30.DeliveryCost; result.AddressId = p30.AddressId; diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs index eb3eda4..6305892 100644 --- a/NetinaShop.Domain/MapsterRegister.cs +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -51,6 +51,20 @@ public class MapsterRegister : IRegister .IgnoreNullValues(false) .TwoWays(); + config.NewConfig() + .Map("Province", o => o.Address != null ? o.Address.Province : string.Empty) + .Map("City", o => o.Address != null ? o.Address.City : string.Empty) + .Map("Plaque", o => o.Address != null ? o.Address.Plaque : string.Empty) + .Map("LocationLat", o => o.Address != null ? o.Address.LocationLat : 0) + .Map("LocationLong", o => o.Address != null ? o.Address.LocationLong : 0) + .Map("PostalCode", o => o.Address != null ? o.Address.PostalCode : string.Empty) + .Map("ReceiverPhoneNumber", o => o.Address != null ? o.Address.ReceiverPhoneNumber : string.Empty) + .Map("ReceiverFullName", o => o.Address != null ? o.Address.ReceiverFullName : string.Empty) + .Map("Address", o => o.Address != null ? o.Address.Address : string.Empty) + .Map("ShippingMethod", o => o.Shipping != null ? o.Shipping.Name : string.Empty) + .IgnoreNullValues(false) + .TwoWays(); + config.NewConfig() .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs index 7dc4405..79ba509 100644 --- a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs @@ -16,8 +16,7 @@ public class GetOrdersQueryHandler : IRequestHandler orders = _repositoryWrapper .SetRepository() - .TableNoTracking - .Where(o=>o.OrderStatus != OrderStatus.OrderBag); + .TableNoTracking; if (request.DateFilter != null) { diff --git a/NetinaShop.Repository/Migrations/20240229174513_EditOrderAddDeliverAt.Designer.cs b/NetinaShop.Repository/Migrations/20240229174513_EditOrderAddDeliverAt.Designer.cs new file mode 100644 index 0000000..cd9ccd7 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240229174513_EditOrderAddDeliverAt.Designer.cs @@ -0,0 +1,1755 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetinaShop.Repository.Models; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20240229174513_EditOrderAddDeliverAt")] + partial class EditOrderAddDeliverAt + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("double precision"); + + b.Property("Authority") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardPan") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FactorNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TransactionCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("CorporateUserId") + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("Immortal") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsForSaleCooperation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CorporateUserId"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveredAt") + .HasColumnType("timestamp without time zone"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountCodePrice") + .HasColumnType("double precision"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("ProductDiscountPrice") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("DiscountId"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddressId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LatestVersionUsed") + .HasColumnType("double precision"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.NewsletterMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("NewsletterMembers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingUnit") + .IsRequired() + .HasColumnType("text"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("LocationLat") + .HasColumnType("real"); + + b.Property("LocationLong") + .HasColumnType("real"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Plaque") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Province") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverFullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverPhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFavoriteProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsExpressShipping") + .HasColumnType("boolean"); + + b.Property("IsOriginalWarehouse") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsShipBySeller") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkingDays") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Shippings", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("CategoryDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.HasIndex("BrandId"); + + b.HasDiscriminator().HasValue("BrandStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("ProductCategoryStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductStorageFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "CorporateUser") + .WithMany() + .HasForeignKey("CorporateUserId"); + + b.Navigation("CorporateUser"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + 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); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithOne("OrderDelivery") + .HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Address"); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany("Addresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDelivery"); + + b.Navigation("OrderProducts"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240229174513_EditOrderAddDeliverAt.cs b/NetinaShop.Repository/Migrations/20240229174513_EditOrderAddDeliverAt.cs new file mode 100644 index 0000000..4627990 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240229174513_EditOrderAddDeliverAt.cs @@ -0,0 +1,32 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditOrderAddDeliverAt : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DeliveredAt", + schema: "public", + table: "Orders", + type: "timestamp without time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DeliveredAt", + schema: "public", + table: "Orders"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index fcba2d8..2b5fbe7 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -463,6 +463,9 @@ namespace NetinaShop.Repository.Migrations b.Property("CreatedBy") .HasColumnType("text"); + b.Property("DeliveredAt") + .HasColumnType("timestamp without time zone"); + b.Property("DeliveryPrice") .HasColumnType("double precision"); diff --git a/Tools/NetinaShop.WordPressDBConverter/Program.cs b/Tools/NetinaShop.WordPressDBConverter/Program.cs index 4c88ba6..783caff 100644 --- a/Tools/NetinaShop.WordPressDBConverter/Program.cs +++ b/Tools/NetinaShop.WordPressDBConverter/Program.cs @@ -9,124 +9,126 @@ using Newtonsoft.Json; Console.ReadKey(); -try -{ - var termReader = new StreamReader("F:\\wp_terms.json"); - var termJson = termReader.ReadToEnd(); - Console.WriteLine("Terms File Read Success !"); - var terms = JsonConvert.DeserializeObject>(termJson); - if (terms == null) - throw new Exception("Terms is null"); - - var termTaxonomyReader = new StreamReader("F:\\wp_term_taxonomy.json"); - var termTaxonomyJson = termTaxonomyReader.ReadToEnd(); - Console.WriteLine("Term Taxonomy File Read Success !"); - var termTaxonomies = JsonConvert.DeserializeObject>(termTaxonomyJson); - if (termTaxonomies == null) - throw new Exception("Term Taxonomies is null"); - var termRelationshipsReader = new StreamReader("F:\\wp_term_relationships.json"); - var termRelationshipsJson = termRelationshipsReader.ReadToEnd(); - Console.WriteLine("Term Relationships File Read Success !"); - var termRelationships = JsonConvert.DeserializeObject>(termRelationshipsJson); - if (termRelationships == null) - throw new Exception("Term Relationships is null"); +//try +//{ +// var termReader = new StreamReader("F:\\wp_terms.json"); +// var termJson = termReader.ReadToEnd(); +// Console.WriteLine("Terms File Read Success !"); +// var terms = JsonConvert.DeserializeObject>(termJson); +// if (terms == null) +// throw new Exception("Terms is null"); - var postReader = new StreamReader("F:\\wp_posts.json"); - var json = postReader.ReadToEnd(); - Console.WriteLine("Post File Read Success !"); - var posts = JsonConvert.DeserializeObject>(json); - if (posts == null) - throw new Exception("Posts is null"); +// var termTaxonomyReader = new StreamReader("F:\\wp_term_taxonomy.json"); +// var termTaxonomyJson = termTaxonomyReader.ReadToEnd(); +// Console.WriteLine("Term Taxonomy File Read Success !"); +// var termTaxonomies = JsonConvert.DeserializeObject>(termTaxonomyJson); +// if (termTaxonomies == null) +// throw new Exception("Term Taxonomies is null"); - var metaReader = new StreamReader("F:\\wp_postmeta.json"); - var metaJson = metaReader.ReadToEnd(); - Console.WriteLine("Post Metas File Read Success !"); - var postMetas = JsonConvert.DeserializeObject>(metaJson); - if (postMetas == null) - throw new Exception("Post Metas is null"); +// var termRelationshipsReader = new StreamReader("F:\\wp_term_relationships.json"); +// var termRelationshipsJson = termRelationshipsReader.ReadToEnd(); +// Console.WriteLine("Term Relationships File Read Success !"); +// var termRelationships = JsonConvert.DeserializeObject>(termRelationshipsJson); +// if (termRelationships == null) +// throw new Exception("Term Relationships is null"); -//CREATE CATEGORY PART - List categories = new List(); - foreach (var taxonomy in termTaxonomies) - { - if (taxonomy.taxonomy == "product_cat") - { - var term = terms.FirstOrDefault(t => t.term_id == taxonomy.term_id); - if (term != null) - categories.Add(new SeedCategoryRequestDto - { BaseCategoryId = term.term_id.ToInt(), Description = taxonomy.description, Name = term.name }); - } - } +// var postReader = new StreamReader("F:\\wp_posts.json"); +// var json = postReader.ReadToEnd(); +// Console.WriteLine("Post File Read Success !"); +// var posts = JsonConvert.DeserializeObject>(json); +// if (posts == null) +// throw new Exception("Posts is null"); - var categoriesRest = await RestWrapper.Instance.SeedRestApi.SeedCategoriesAsync(categories,"kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A=="); - Console.WriteLine($"{categories.Count} ProductCategory Added Success !"); - //CREATE BRAND PART - List brands = new List(); - foreach (var taxonomy in termTaxonomies) - { - if (taxonomy.taxonomy == "pa_brand") - { - var term = terms.FirstOrDefault(t => t.term_id == taxonomy.term_id); - if (term != null) - brands.Add(new SeedBrandRequestDto{BaseBrandId = term.term_id.ToInt(),Description = taxonomy.description,Name = term.name}); - } - } - var brandsRest = await RestWrapper.Instance.SeedRestApi.SeedBrandsAsync(brands, "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A=="); +// var metaReader = new StreamReader("F:\\wp_postmeta.json"); +// var metaJson = metaReader.ReadToEnd(); +// Console.WriteLine("Post Metas File Read Success !"); +// var postMetas = JsonConvert.DeserializeObject>(metaJson); +// if (postMetas == null) +// throw new Exception("Post Metas is null"); - Console.WriteLine($"{brands.Count} Brand Added Success !"); - //CREATE PRODUCT PART - List products = new List(); - foreach (var wordPressPostDto in posts.Where(p => p.post_type == "product")) - { - CreateProductCommand product; - Guid brandId = default; - Guid categoryId = default; - var postTermRelations = termRelationships.Where(p => p.object_id == wordPressPostDto.ID); - foreach (var postTermRelation in postTermRelations) - { - var taxanomy = termTaxonomies.FirstOrDefault(f => f.term_taxonomy_id == postTermRelation.term_taxonomy_id); - if (taxanomy != null) - { - if (taxanomy.taxonomy == "pa_brand") - brandId = brandsRest.FirstOrDefault(f => f.Key == taxanomy.term_id.ToInt()).Value; - if (taxanomy.taxonomy == "product_cat") - categoryId = categoriesRest.FirstOrDefault(c => c.Key == taxanomy.term_id.ToInt()).Value; - } - } +////CREATE CATEGORY PART +// List categories = new List(); +// foreach (var taxonomy in termTaxonomies) +// { +// if (taxonomy.taxonomy == "product_cat") +// { +// var term = terms.FirstOrDefault(t => t.term_id == taxonomy.term_id); +// if (term != null) +// categories.Add(new SeedCategoryRequestDto +// { BaseCategoryId = term.term_id.ToInt(), Description = taxonomy.description, Name = term.name }); +// } +// } - if (brandId == default) - brandId = brandsRest.FirstOrDefault(f => f.Key == 0).Value; - if (categoryId == default) - categoryId = categoriesRest.FirstOrDefault(c => c.Key == 0).Value; - var price = postMetas.FirstOrDefault(pm => pm.post_id == wordPressPostDto.ID && pm.meta_key == "_price"); - if (price != null && double.TryParse(price.meta_value, out double dPrice)) - product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content, - wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, dPrice, 0,10, - false,10,false,brandId, categoryId, - new DiscountSDto(),new List(), new List()); - else - product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content, - wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, 0, 0,10,false,10, - false,brandId,categoryId, - new DiscountSDto(),new List(), new List()); +// var categoriesRest = await RestWrapper.Instance.SeedRestApi.SeedCategoriesAsync(categories,"kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A=="); +// Console.WriteLine($"{categories.Count} ProductCategory Added Success !"); - products.Add(product); - } +// //CREATE BRAND PART +// List brands = new List(); +// foreach (var taxonomy in termTaxonomies) +// { +// if (taxonomy.taxonomy == "pa_brand") +// { +// var term = terms.FirstOrDefault(t => t.term_id == taxonomy.term_id); +// if (term != null) +// brands.Add(new SeedBrandRequestDto{BaseBrandId = term.term_id.ToInt(),Description = taxonomy.description,Name = term.name}); +// } +// } +// var brandsRest = await RestWrapper.Instance.SeedRestApi.SeedBrandsAsync(brands, "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A=="); - for (int i = 0; i < products.Count / 50 ; i++) - { - await RestWrapper.Instance.SeedRestApi.SeedProductsAsync(products.Skip(i * 50).Take(50).ToList(), - "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A=="); +// Console.WriteLine($"{brands.Count} Brand Added Success !"); +// //CREATE PRODUCT PART +// List products = new List(); +// foreach (var wordPressPostDto in posts.Where(p => p.post_type == "product")) +// { +// CreateProductCommand product; +// Guid brandId = default; +// Guid categoryId = default; +// var postTermRelations = termRelationships.Where(p => p.object_id == wordPressPostDto.ID); +// foreach (var postTermRelation in postTermRelations) +// { +// var taxanomy = termTaxonomies.FirstOrDefault(f => f.term_taxonomy_id == postTermRelation.term_taxonomy_id); +// if (taxanomy != null) +// { +// if (taxanomy.taxonomy == "pa_brand") +// brandId = brandsRest.FirstOrDefault(f => f.Key == taxanomy.term_id.ToInt()).Value; +// if (taxanomy.taxonomy == "product_cat") +// categoryId = categoriesRest.FirstOrDefault(c => c.Key == taxanomy.term_id.ToInt()).Value; +// } +// } - Console.WriteLine($"{i*50} / {products.Count} Product Added Success !"); - } -} -catch (Exception e) -{ - Console.WriteLine(e); - throw; -} \ No newline at end of file +// if (brandId == default) +// brandId = brandsRest.FirstOrDefault(f => f.Key == 0).Value; +// if (categoryId == default) +// categoryId = categoriesRest.FirstOrDefault(c => c.Key == 0).Value; +// var price = postMetas.FirstOrDefault(pm => pm.post_id == wordPressPostDto.ID && pm.meta_key == "_price"); +// if (price != null && double.TryParse(price.meta_value, out double dPrice)) +// product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content, +// wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, dPrice, 0,10, +// false,10,false,brandId, categoryId, +// new DiscountSDto(),new List(), new List()); +// else +// product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content, +// wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, 0, 0,10,false,10, +// false,brandId,categoryId, +// new DiscountSDto(),new List(), new List()); + +// products.Add(product); +// } + +// for (int i = 0; i < products.Count / 50 ; i++) +// { +// await RestWrapper.Instance.SeedRestApi.SeedProductsAsync(products.Skip(i * 50).Take(50).ToList(), +// "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A=="); + +// Console.WriteLine($"{i*50} / {products.Count} Product Added Success !"); +// } +//} +//catch (Exception e) +//{ +// Console.WriteLine(e); +// throw; +//} \ No newline at end of file