From 24ca6e859ce13a32bce0089c8bcb7a07fdca4d1a Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Mon, 12 Feb 2024 22:01:15 +0330 Subject: [PATCH] add marten --- .../AppSettings/appsettings.Development.json | 1 + .../Controller/OrderBagController.cs | 3 +- NetinaShop.Api/Controller/PageController.cs | 63 + .../Controller/SettingController.cs | 51 + .../Controller/UserAddressController.cs | 32 + NetinaShop.Api/Controller/UserController.cs | 13 + NetinaShop.Api/NetinaShop.Api.csproj | 3 +- NetinaShop.Api/Program.cs | 1 + .../Configurations/ServiceExtensions.cs | 21 +- .../Extensions/ClassDisplayExtensions.cs | 4 +- .../{ClassDisplay.cs => PageClassDisplay.cs} | 4 +- .../CoreServices/Abstracts/IPageService.cs | 10 + NetinaShop.Core/CoreServices/PageService.cs | 85 + .../SubmitDiscountCommandHandler.cs | 8 +- .../SubmitOrderDeliveryCommandHandler.cs | 29 +- .../CalculateOrderCommandHandler.cs | 3 +- .../Commands/AddressCommands.cs | 28 + .../Commands/OrderBagCommands.cs | 4 +- .../Commands/ShippingCommands.cs | 6 +- .../CommandQueries/Queries/AddressQueries.cs | 4 + .../Dtos/RequestDtos/PageActionRequestDto.cs | 14 + .../Dtos/SmallDtos/BasePageEntitySDto.cs | 14 + .../Dtos/SmallDtos/OrderDeliverySDto.cs | 7 + .../Dtos/SmallDtos/ShippingSDto.cs | 1 + .../Dtos/SmallDtos/UserAddressSDto.cs | 16 + .../Entities/Orders/Order.Aggregate.cs | 8 +- .../Entities/Orders/OrderDelivery.cs | 15 +- .../Entities/Pages/BasePageEntity.cs | 14 + NetinaShop.Domain/Entities/Pages/FAQPage.cs | 7 + .../Entities/Settings/PaymentSetting.cs | 9 + .../Entities/Users/User.Aggreage.cs | 13 + .../Entities/Users/UserAddress.cs | 31 +- .../Entities/Warehouses/Shipping.cs | 4 +- .../Warehouses/Warehouses.Aggregate.cs | 4 +- NetinaShop.Domain/Enums/OrderPaymentMethod.cs | 4 +- NetinaShop.Domain/Mappers/OrderMapper.g.cs | 30 +- NetinaShop.Domain/Mappers/ShippingMapper.g.cs | 5 + .../Mappers/UserAddressMapper.g.cs | 113 ++ .../DbContextOptionCustomExtensionsInfo.cs | 5 +- .../Extensions/ModelBuilderExtensions.cs | 4 +- .../Accounting/GetPaymentQueryHandler.cs | 3 +- .../Accounting/GetPaymentsQueryHandler.cs | 3 +- .../Accounting/UpdatePaymentCommandHandler.cs | 3 +- .../Addresses/CreateAddressCommandHandler.cs | 28 + .../Addresses/DeleteAddressCommandHandler.cs | 25 + .../Addresses/GetUserAddressesQueryHandler.cs | 35 + .../Brands/DeleteBrandCommandHandler.cs | 3 +- .../Handlers/Brands/GetBrandsQueryHandler.cs | 3 +- .../Brands/UpdateBrandCommandHandler.cs | 3 +- .../Discounts/DeleteDiscountCommandHandler.cs | 4 +- .../Discounts/GetDiscountQueryHandler.cs | 4 +- .../Discounts/GetDiscountsQueryHandler.cs | 4 +- .../Discounts/UpdateDiscountCommandHandler.cs | 4 +- .../Orders/DeleteOrderCommandHandler.cs | 3 +- .../Orders/GetOrderLDtoQueryHandler.cs | 3 +- .../Handlers/Orders/GetOrderQueryHandler.cs | 5 +- .../Handlers/Orders/GetOrdersQueryHandler.cs | 3 +- .../DeleteProductCategoryCommandHandler.cs | 3 +- .../GetProductCategoriesQueryHandler.cs | 3 +- .../GetProductCategoryChildrenQueryHandler.cs | 1 + .../GetProductCategoryQueryHandler.cs | 3 +- .../UpdateProductCategoryCommandHandler.cs | 3 +- .../Products/DeleteProductCommandHandler.cs | 4 +- .../Products/GetProductQueryHandler.cs | 4 +- .../Products/GetProductsQueryHandler.cs | 3 +- .../Products/UpdateProductCommandHandler.cs | 4 +- .../Reviews/CreateReviewCommandHandler.cs | 3 +- .../Reviews/DeleteReviewCommandHandler.cs | 4 +- .../Handlers/Reviews/GetReviewQueryHandler.cs | 4 +- .../Reviews/GetReviewsQueryHandler.cs | 4 +- .../CreateShippingCommandHandler.cs | 2 +- .../DeleteShippingCommandHandler.cs | 3 +- .../Warehouses/GetShippingQueryHandler.cs | 3 +- .../Warehouses/GetShippingsQueryHandler.cs | 3 +- .../UpdateShippingCommandHandler.cs | 5 +- .../20240212114249_EditAddress.Designer.cs | 1679 ++++++++++++++++ .../Migrations/20240212114249_EditAddress.cs | 70 + ...400_EditShippingAddWorkingDays.Designer.cs | 1682 +++++++++++++++++ ...240212160400_EditShippingAddWorkingDays.cs | 31 + ...72112_EditShippingAddAddressId.Designer.cs | 1678 ++++++++++++++++ ...20240212172112_EditShippingAddAddressId.cs | 110 ++ .../ApplicationContextModelSnapshot.cs | 45 +- .../Models/ApplicationContext.cs | 5 +- .../NetinaShop.Repository.csproj | 6 +- .../Repositories/Base/BaseRepository.cs | 4 +- .../Base/Contracts/IReadRepository.cs | 4 +- .../Base/Contracts/IRepository.cs | 4 +- .../Repositories/Base/ReadRepository.cs | 4 +- .../Repositories/Base/Repository.cs | 4 +- .../Repositories/Base/RepositoryWrapper.cs | 6 +- .../Repositories/Base/WriteRepository.cs | 2 + .../Entity/Abstracts/IDiscountRepository.cs | 5 - .../Entity/Abstracts/IMartenRepository.cs | 15 + .../Entity/Abstracts/IProductRepository.cs | 6 - .../Repositories/Entity/DiscountRepository.cs | 9 - .../Repositories/Entity/MartenRepository.cs | 60 + .../Repositories/Entity/ProductRepository.cs | 11 - .../Repositories/UnitOfWork/UnitOfWork.cs | 6 +- .../Services/DbInitializerService.cs | 4 +- 99 files changed, 6171 insertions(+), 165 deletions(-) create mode 100644 NetinaShop.Api/Controller/PageController.cs create mode 100644 NetinaShop.Api/Controller/SettingController.cs create mode 100644 NetinaShop.Api/Controller/UserAddressController.cs rename NetinaShop.Common/Models/Entity/{ClassDisplay.cs => PageClassDisplay.cs} (80%) create mode 100644 NetinaShop.Core/CoreServices/Abstracts/IPageService.cs create mode 100644 NetinaShop.Core/CoreServices/PageService.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/AddressCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/AddressQueries.cs create mode 100644 NetinaShop.Domain/Dtos/RequestDtos/PageActionRequestDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/BasePageEntitySDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/UserAddressSDto.cs create mode 100644 NetinaShop.Domain/Entities/Pages/BasePageEntity.cs create mode 100644 NetinaShop.Domain/Entities/Pages/FAQPage.cs create mode 100644 NetinaShop.Domain/Entities/Settings/PaymentSetting.cs create mode 100644 NetinaShop.Domain/Entities/Users/User.Aggreage.cs create mode 100644 NetinaShop.Domain/Mappers/UserAddressMapper.g.cs create mode 100644 NetinaShop.Repository/Handlers/Addresses/CreateAddressCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Addresses/DeleteAddressCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Addresses/GetUserAddressesQueryHandler.cs create mode 100644 NetinaShop.Repository/Migrations/20240212114249_EditAddress.Designer.cs create mode 100644 NetinaShop.Repository/Migrations/20240212114249_EditAddress.cs create mode 100644 NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.Designer.cs create mode 100644 NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.cs create mode 100644 NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.Designer.cs create mode 100644 NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.cs delete mode 100644 NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs create mode 100644 NetinaShop.Repository/Repositories/Entity/Abstracts/IMartenRepository.cs delete mode 100644 NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs delete mode 100644 NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs create mode 100644 NetinaShop.Repository/Repositories/Entity/MartenRepository.cs delete mode 100644 NetinaShop.Repository/Repositories/Entity/ProductRepository.cs diff --git a/NetinaShop.Api/AppSettings/appsettings.Development.json b/NetinaShop.Api/AppSettings/appsettings.Development.json index 83b7d93..417f3bb 100644 --- a/NetinaShop.Api/AppSettings/appsettings.Development.json +++ b/NetinaShop.Api/AppSettings/appsettings.Development.json @@ -2,6 +2,7 @@ "ConnectionStrings": { "PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;", "Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS", + "Marten": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopSettingsDB;", "SettingDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopSettingDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS" }, "Logging": { diff --git a/NetinaShop.Api/Controller/OrderBagController.cs b/NetinaShop.Api/Controller/OrderBagController.cs index e150d2a..ffa74e4 100644 --- a/NetinaShop.Api/Controller/OrderBagController.cs +++ b/NetinaShop.Api/Controller/OrderBagController.cs @@ -51,8 +51,7 @@ public class OrderBagController : ICarterModule => TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken)); public async Task AddShippingToOrderBagAsync(Guid orderId, [FromBody] SubmitOrderDeliveryCommand request, IMediator mediator, CancellationToken cancellationToken) - => TypedResults.Ok( await mediator.Send(new SubmitOrderDeliveryCommand(request.Address, request.PostalCode, - request.ReceiverPhoneNumber, request.ReceiverFullName, orderId, request.ShippingId), cancellationToken)); + => TypedResults.Ok( await mediator.Send(new SubmitOrderDeliveryCommand(request.AddressId, orderId, request.ShippingId), cancellationToken)); public async Task SubmitOrderPaymentAsync(Guid orderId, [FromQuery] OrderPaymentMethod paymentMethod, IMediator mediator, CancellationToken cancellationToken) => TypedResults.Ok( await mediator.Send(new SubmitOrderPaymentCommand(orderId, paymentMethod), cancellationToken)); diff --git a/NetinaShop.Api/Controller/PageController.cs b/NetinaShop.Api/Controller/PageController.cs new file mode 100644 index 0000000..3cfe0a0 --- /dev/null +++ b/NetinaShop.Api/Controller/PageController.cs @@ -0,0 +1,63 @@ +using NetinaShop.Repository.Repositories.Entity.Abstracts; +using System.Reflection; +using System.Text.Json; + +namespace NetinaShop.Api.Controller; + +public class PageController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Pages") + .MapGroup("api/page"); + + group.MapGet("", GetPagesAsync) + .WithDisplayName("Get Pages") + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + + group.MapGet("{id}", GetPageByIdAsync) + .WithDisplayName("Get Page") + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("slug/{pageSlug}", GetPageAsync) + .WithDisplayName("Get Page") + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("type/{type}", GetPageByTypeAsync) + .WithDisplayName("Get Page") + .HasApiVersion(1.0); + + group.MapPost("", PostPageAsync) + .WithDisplayName("Post Page") + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + } + public async Task GetPagesAsync(Guid id, [FromServices] IPageService pageService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await pageService.GetPagesAsync(cancellationToken)); + } + + public async Task GetPageByIdAsync(Guid id ,[FromServices] IPageService pageService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await pageService.GetPageAsync(id: id,cancellationToken: cancellationToken)); + } + public async Task GetPageByTypeAsync(string type, [FromServices] IPageService pageService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await pageService.GetPageAsync(type: type, cancellationToken: cancellationToken)); + } + + public async Task GetPageAsync(string pageSlug, [FromServices] IPageService pageService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await pageService.GetPageAsync(pageSlug: pageSlug,cancellationToken: cancellationToken)); + } + + public async Task PostPageAsync([FromBody] PageActionRequestDto page, [FromServices] IPageService pageService, CancellationToken cancellationToken) + { + await pageService.CreatePageAsync(page, cancellationToken); + return TypedResults.Ok(); + } +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/SettingController.cs b/NetinaShop.Api/Controller/SettingController.cs new file mode 100644 index 0000000..37694dc --- /dev/null +++ b/NetinaShop.Api/Controller/SettingController.cs @@ -0,0 +1,51 @@ +using System.Reflection; +using System.Text.Json; +using NetinaShop.Repository.Repositories.Entity.Abstracts; + +namespace NetinaShop.Api.Controller; + +public class SettingController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Setting") + .MapGroup("api/setting") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("{settingName}", GetSettingAsync) + .WithDisplayName("GetSetting") + .HasApiVersion(1.0); + group.MapPost("{settingName}", PostSettingAsync) + .WithDisplayName("PostSettingAsync") + .HasApiVersion(1.0); + } + + public async Task GetSettingAsync(string settingName, [FromServices] IMartenRepository martenRepository, CancellationToken cancellationToken) + { + var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType($"NetinaShop.Domain.Entities.Settings.{settingName}"); + if (type == null) + throw new AppException("Setting not found", ApiResultStatusCode.NotFound); + + var setting = await ((dynamic)martenRepository.GetType()?.GetMethod("GetEntityAsync") + ?.MakeGenericMethod(type) + .Invoke(martenRepository,new object[]{ cancellationToken })!); + if (setting == null) + setting = Activator.CreateInstance(type); + + return TypedResults.Ok(setting); + } + + public async Task PostSettingAsync(string settingName, [FromBody]JsonDocument settingObj, [FromServices] IMartenRepository martenRepository, CancellationToken cancellationToken) + { + var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType($"NetinaShop.Domain.Entities.Settings.{settingName}"); + if (type == null) + throw new AppException("Setting not found", ApiResultStatusCode.NotFound); + var setting = settingObj.Deserialize(type); + if (setting == null) + throw new AppException("Setting not found", ApiResultStatusCode.NotFound); + await ((dynamic)martenRepository.GetType().GetMethod("AddOrUpdateEntityAsync") + ?.MakeGenericMethod(type).Invoke(martenRepository, new[] { setting , cancellationToken })!); + + return TypedResults.Ok(); + } +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/UserAddressController.cs b/NetinaShop.Api/Controller/UserAddressController.cs new file mode 100644 index 0000000..c86cca1 --- /dev/null +++ b/NetinaShop.Api/Controller/UserAddressController.cs @@ -0,0 +1,32 @@ +namespace NetinaShop.Api.Controller; + +public class UserAddressController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("UserAddress") + .MapGroup("api/user/address") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAddressesAsync) + .WithDisplayName("Get Addresses") + .HasApiVersion(1.0); + + group.MapPost("", PostAddressesAsync) + .WithDisplayName("Post Addresses") + .HasApiVersion(1.0); + + group.MapDelete("{id}", DeleteAddressesAsync) + .WithDisplayName("Delete Address") + .HasApiVersion(1.0); + } + + public async Task GetAddressesAsync([FromServices] IMediator mediator,CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetUserAddressesQuery(null), cancellationToken)); + + public async Task PostAddressesAsync([FromBody] CreateAddressCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + public async Task DeleteAddressesAsync(Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteAddressCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/UserController.cs b/NetinaShop.Api/Controller/UserController.cs index 4e48fae..cea61e4 100644 --- a/NetinaShop.Api/Controller/UserController.cs +++ b/NetinaShop.Api/Controller/UserController.cs @@ -1,5 +1,7 @@  +using Microsoft.AspNetCore.Mvc.RazorPages; using NetinaShop.Core.EntityServices.Abstracts; +using NetinaShop.Repository.Abstracts; namespace NetinaShop.Api.Controller; @@ -12,6 +14,10 @@ public class UserController : ICarterModule .MapGroup($"api/user") .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + group.MapGet("info", GetUserInfoAsync) + .WithDisplayName("GetUserInfo") + .HasApiVersion(1.0); + group.MapGet("", GetAllAsync) .WithDisplayName("GetAllUsers") .HasApiVersion(1.0); @@ -30,6 +36,13 @@ public class UserController : ICarterModule .HasApiVersion(1.0); } + public async Task GetUserInfoAsync(IUserService userService,ICurrentUserService currentUserService, CancellationToken cancellationToken) + { + + if (!Guid.TryParse(currentUserService.UserId, out var userId)) + throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized); + return TypedResults.Ok(await userService.GetUserAsync(userId, cancellationToken)); + } // GET:Get All Entity public async Task GetAllAsync([FromQuery] int page, [FromQuery]string? phoneNumber, IUserService userService, CancellationToken cancellationToken) => TypedResults.Ok(await userService.GetUsersAsync(page,phoneNumber,cancellationToken)); diff --git a/NetinaShop.Api/NetinaShop.Api.csproj b/NetinaShop.Api/NetinaShop.Api.csproj index d3d373e..4123309 100644 --- a/NetinaShop.Api/NetinaShop.Api.csproj +++ b/NetinaShop.Api/NetinaShop.Api.csproj @@ -20,7 +20,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -37,7 +37,6 @@ - diff --git a/NetinaShop.Api/Program.cs b/NetinaShop.Api/Program.cs index 4c02748..8ac91dc 100644 --- a/NetinaShop.Api/Program.cs +++ b/NetinaShop.Api/Program.cs @@ -36,6 +36,7 @@ builder.Services.AddJwtCustomAuthentication(siteSetting.JwtSettings); builder.Services.AddMvcCore().AddRazorPages().AddRazorViewEngine().AddViews(); builder.Services.AddCustomIdentity(); builder.Services.AddCustomDbContext(configuration); +builder.Services.AddMarten(configuration,builder.Environment); builder.Services.AddCarter(); diff --git a/NetinaShop.Api/WebFramework/Configurations/ServiceExtensions.cs b/NetinaShop.Api/WebFramework/Configurations/ServiceExtensions.cs index df7b011..a46fe65 100644 --- a/NetinaShop.Api/WebFramework/Configurations/ServiceExtensions.cs +++ b/NetinaShop.Api/WebFramework/Configurations/ServiceExtensions.cs @@ -1,4 +1,7 @@ -namespace NetinaShop.Api.WebFramework.Configurations; +using Marten; +using Weasel.Core; + +namespace NetinaShop.Api.WebFramework.Configurations; public static class ServiceExtensions { @@ -58,6 +61,22 @@ public static class ServiceExtensions AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); } + public static void AddMarten(this IServiceCollection serviceCollection, IConfigurationRoot configuration , IWebHostEnvironment environment) + { + serviceCollection.AddMarten(options => + { + // Establish the connection string to your Marten database + options.Connection(configuration.GetConnectionString("Marten")!); + + // If we're running in development mode, let Marten just take care + // of all necessary schema building and patching behind the scenes + if (environment.IsDevelopment()) + { + options.AutoCreateSchemaObjects = AutoCreate.All; + } + }); + } + public static void AddCustomResponseCompression(this IServiceCollection serviceCollection) { serviceCollection.Configure(options => diff --git a/NetinaShop.Common/Extensions/ClassDisplayExtensions.cs b/NetinaShop.Common/Extensions/ClassDisplayExtensions.cs index aa30ad7..883709a 100644 --- a/NetinaShop.Common/Extensions/ClassDisplayExtensions.cs +++ b/NetinaShop.Common/Extensions/ClassDisplayExtensions.cs @@ -11,7 +11,7 @@ namespace NetinaShop.Common.Extensions foreach (var attr in attrs) { - var displayAttribute = attr as ClassDisplay; + var displayAttribute = attr as PageClassDisplay; if (displayAttribute == null) continue; return displayAttribute.GetName(); @@ -27,7 +27,7 @@ namespace NetinaShop.Common.Extensions foreach (var attr in attrs) { - var displayAttribute = attr as ClassDisplay; + var displayAttribute = attr as PageClassDisplay; if (displayAttribute == null) continue; return displayAttribute.GetDescription(); diff --git a/NetinaShop.Common/Models/Entity/ClassDisplay.cs b/NetinaShop.Common/Models/Entity/PageClassDisplay.cs similarity index 80% rename from NetinaShop.Common/Models/Entity/ClassDisplay.cs rename to NetinaShop.Common/Models/Entity/PageClassDisplay.cs index ec02461..d07ed5b 100644 --- a/NetinaShop.Common/Models/Entity/ClassDisplay.cs +++ b/NetinaShop.Common/Models/Entity/PageClassDisplay.cs @@ -1,12 +1,12 @@ namespace NetinaShop.Common.Models.Entity { [AttributeUsage(AttributeTargets.Class)] - public class ClassDisplay : Attribute + public class PageClassDisplay : Attribute { private readonly string _description; private readonly string _name; - public ClassDisplay(string name, string description) + public PageClassDisplay(string name, string description) { _name = name; _description = description; diff --git a/NetinaShop.Core/CoreServices/Abstracts/IPageService.cs b/NetinaShop.Core/CoreServices/Abstracts/IPageService.cs new file mode 100644 index 0000000..6a4cc1a --- /dev/null +++ b/NetinaShop.Core/CoreServices/Abstracts/IPageService.cs @@ -0,0 +1,10 @@ +using NetinaShop.Domain.Entities.Pages; + +namespace NetinaShop.Core.CoreServices.Abstracts; + +public interface IPageService : IScopedDependency +{ + Task GetPageAsync(Guid? id = null, string? pageName = null, string? pageSlug = null,string? type = null, CancellationToken cancellationToken=default); + Task> GetPagesAsync(CancellationToken cancellationToken = default); + Task CreatePageAsync(PageActionRequestDto entity, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/NetinaShop.Core/CoreServices/PageService.cs b/NetinaShop.Core/CoreServices/PageService.cs new file mode 100644 index 0000000..592334b --- /dev/null +++ b/NetinaShop.Core/CoreServices/PageService.cs @@ -0,0 +1,85 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; +using NetinaShop.Domain.Entities.Pages; +using NetinaShop.Repository.Repositories.Entity.Abstracts; + +namespace NetinaShop.Core.CoreServices; + +public class PageService : IPageService +{ + private readonly IMartenRepository _martenRepository; + + public PageService(IMartenRepository martenRepository) + { + _martenRepository = martenRepository; + } + public async Task GetPageAsync(Guid? id = null, string? pageName = null, string? pageSlug = null, string? type = null, CancellationToken cancellationToken = default) + { + BasePageEntity? page = null; + if (id != null) + page = await _martenRepository.GetEntityAsync(id.Value, cancellationToken); + else if (pageSlug != null) + page = await _martenRepository.GetEntityAsync(entity => entity.Slug == pageSlug, cancellationToken); + else if (pageName != null) + page = await _martenRepository.GetEntityAsync(entity => entity.Name == pageName, cancellationToken); + else if (type != null) + page = await _martenRepository.GetEntityAsync(entity => entity.Type == type, cancellationToken); + if (page == null) + throw new AppException("Page not found",ApiResultStatusCode.NotFound); + + var dto = new BasePageEntitySDto + { + + Content = page.Content, + Description = page.Description, + Id = page.Id, + IsCustomPage = page.IsCustomPage, + IsHtmlBasePage = page.IsHtmlBasePage, + Name = page.Name, + Slug = page.Slug, + Data = JsonConvert.DeserializeObject(page.Data) + }; + + return dto; + } + + public async Task> GetPagesAsync(CancellationToken cancellationToken = default) + { + List sDtos = new List(); + var pages = await _martenRepository.GetEntitiesAsync(cancellationToken); + foreach (var page in pages) + { + var dto = new BasePageEntitySDto + { + + Content = page.Content, + Description = page.Description, + Id = page.Id, + IsCustomPage = page.IsCustomPage, + IsHtmlBasePage = page.IsHtmlBasePage, + Name = page.Name, + Slug = page.Slug, + Data = JsonConvert.DeserializeObject(page.Data) + }; + sDtos.Add(dto); + } + return sDtos; + } + + public async Task CreatePageAsync(PageActionRequestDto entity, CancellationToken cancellationToken = default) + { + var basePage = new BasePageEntity + { + Content = entity.Content, + Description = entity.Description, + Id = entity.Id, + IsCustomPage = entity.IsCustomPage, + IsHtmlBasePage = entity.IsHtmlBasePage, + Name = entity.Name, + Type = entity.Type, + Slug = entity.Slug, + Data = JsonConvert.SerializeObject(entity.Data) + }; + await _martenRepository.AddOrUpdateEntityAsync(basePage, cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitDiscountCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitDiscountCommandHandler.cs index 3b14a09..6733ba6 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitDiscountCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitDiscountCommandHandler.cs @@ -1,6 +1,6 @@ namespace NetinaShop.Core.EntityServices.OrderBagHandlers; -public class SubmitDiscountCommandHandler : IRequestHandler +public class SubmitDiscountCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; private readonly IMediator _mediator; @@ -10,7 +10,7 @@ public class SubmitDiscountCommandHandler : IRequestHandler Handle(SubmitDiscountCommand request, CancellationToken cancellationToken) + public async Task Handle(SubmitDiscountCommand request, CancellationToken cancellationToken) { var order = await _repositoryWrapper.SetRepository() .TableNoTracking @@ -25,8 +25,8 @@ public class SubmitDiscountCommandHandler : IRequestHandler().Update(order); await _repositoryWrapper.SaveChangesAsync(cancellationToken); - await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); + var calculateOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); - return true; + return calculateOrder.AdaptToSDto(); } } \ No newline at end of file diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderDeliveryCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderDeliveryCommandHandler.cs index 547d710..bcfc045 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderDeliveryCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderDeliveryCommandHandler.cs @@ -2,7 +2,7 @@ namespace NetinaShop.Core.EntityServices.OrderBagHandlers; -public class SubmitOrderDeliveryCommandHandler : IRequestHandler +public class SubmitOrderDeliveryCommandHandler : IRequestHandler { private readonly IMediator _mediator; private readonly IRepositoryWrapper _repositoryWrapper; @@ -12,7 +12,7 @@ public class SubmitOrderDeliveryCommandHandler : IRequestHandler Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken) + public async Task Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken) { var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken); var shipping = await _repositoryWrapper.SetRepository() @@ -20,18 +20,27 @@ public class SubmitOrderDeliveryCommandHandler : IRequestHandler s.Id == request.ShippingId, cancellationToken); if (shipping == null) throw new AppException("Shipping not found", ApiResultStatusCode.NotFound); - foreach (var orderDelivery in order.OrderDeliveries) + if (order.OrderDeliveries.Count > 0) { - _repositoryWrapper.SetRepository() - .Delete(orderDelivery); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + foreach (var orderDelivery in order.OrderDeliveries) + { + var newEnt = OrderDelivery.Create(request.AddressId, shipping.DeliveryCost, request.ShippingId, + request.OrderId); + newEnt.CreatedAt = orderDelivery.CreatedAt; + newEnt.CreatedBy = orderDelivery.CreatedBy; + newEnt.Id = orderDelivery.Id; + _repositoryWrapper.SetRepository() + .Update(newEnt); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + order.OrderDeliveries.Clear(); } - order.OrderDeliveries.Clear(); - order.AddOrderDelivery(request.Address,request.PostalCode,request.ReceiverPhoneNumber,request.ReceiverFullName,shipping.DeliveryCost,request.ShippingId,request.OrderId); + else + order.AddOrderDelivery(request.AddressId, shipping.DeliveryCost, request.ShippingId, request.OrderId); _repositoryWrapper.SetRepository().Update(order); await _repositoryWrapper.SaveChangesAsync(cancellationToken); - await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); - return true; + var calculatedOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); + return calculatedOrder.AdaptToSDto(); } } \ No newline at end of file diff --git a/NetinaShop.Core/EntityServices/OrderHandlers/CalculateOrderCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderHandlers/CalculateOrderCommandHandler.cs index d95c526..9f1eaa5 100644 --- a/NetinaShop.Core/EntityServices/OrderHandlers/CalculateOrderCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderHandlers/CalculateOrderCommandHandler.cs @@ -35,7 +35,8 @@ public class CalculateOrderCommandHandler : IRequestHandler().Update(order); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return order; diff --git a/NetinaShop.Domain/CommandQueries/Commands/AddressCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/AddressCommands.cs new file mode 100644 index 0000000..e369037 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/AddressCommands.cs @@ -0,0 +1,28 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreateAddressCommand( + string Address, + string Province, + string City, + string Plaque, + string BuildingUnit, + string ReceiverFullName, + string ReceiverPhoneNumber, + string PostalCode, + float LocationLat, + float LocationLong) : IRequest; + +public sealed record UpdateAddressCommand( + Guid Id, + string Address, + string Province, + string City, + string Plaque, + string BuildingUnit, + string ReceiverFullName, + string ReceiverPhoneNumber, + string PostalCode, + float LocationLat, + float LocationLong) : IRequest; + +public sealed record DeleteAddressCommand(Guid Id):IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs index 09d1e03..2c61a92 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs @@ -7,8 +7,8 @@ public sealed record CreateOrderCommand(string DiscountCode, List RequestDtos) : IRequest; public sealed record RemoveFromOrderBagCommand(List RequestDtos) : IRequest; -public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest; -public sealed record SubmitOrderDeliveryCommand(string Address, string PostalCode, string ReceiverPhoneNumber, string ReceiverFullName, Guid OrderId, Guid ShippingId) : IRequest; +public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest; +public sealed record SubmitOrderDeliveryCommand(Guid AddressId, Guid OrderId, Guid ShippingId) : IRequest; public sealed record SubmitOrderPaymentCommand(Guid OrderId, OrderPaymentMethod PaymentMethod , bool HasPaid = false) : IRequest; diff --git a/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs index bb0992a..92bb453 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs @@ -6,7 +6,8 @@ public sealed record CreateShippingCommand ( bool IsExpressShipping, bool IsShipBySeller , bool IsOriginalWarehouse, - double DeliveryCost) : IRequest; + double DeliveryCost, + int WorkingDays) : IRequest; public sealed record UpdateShippingCommand( Guid Id, @@ -15,7 +16,8 @@ public sealed record UpdateShippingCommand( bool IsExpressShipping, bool IsShipBySeller, bool IsOriginalWarehouse, - double DeliveryCost) : IRequest; + double DeliveryCost, + int WorkingDays) : IRequest; public sealed record DeleteShippingCommand( Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/AddressQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/AddressQueries.cs new file mode 100644 index 0000000..3f6952f --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/AddressQueries.cs @@ -0,0 +1,4 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public sealed record GetAddressesQuery():IRequest>; +public sealed record GetUserAddressesQuery(Guid? UserId) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/RequestDtos/PageActionRequestDto.cs b/NetinaShop.Domain/Dtos/RequestDtos/PageActionRequestDto.cs new file mode 100644 index 0000000..6969183 --- /dev/null +++ b/NetinaShop.Domain/Dtos/RequestDtos/PageActionRequestDto.cs @@ -0,0 +1,14 @@ +namespace NetinaShop.Domain.Dtos.RequestDtos; + +public class PageActionRequestDto +{ + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public bool IsCustomPage { get; set; } + public bool IsHtmlBasePage { get; set; } + public string Slug { get; set; } = string.Empty; + public string Type { get; set; } = string.Empty; + public object? Data { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BasePageEntitySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BasePageEntitySDto.cs new file mode 100644 index 0000000..14f8e9e --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/BasePageEntitySDto.cs @@ -0,0 +1,14 @@ +using NetinaShop.Domain.Entities.Pages; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class BasePageEntitySDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public bool IsCustomPage { get; set; } + public bool IsHtmlBasePage { get; set; } + public string Slug { get; set; } = string.Empty; + public object? Data { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs index 9d97b88..cc0d29d 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs @@ -2,11 +2,18 @@ public class OrderDeliverySDto : BaseDto { + public string Province { get; set; } = string.Empty; + public string City { get; set; } = string.Empty; + public string Plaque { get; set; } = string.Empty; + public float LocationLat { get; set; } + public float LocationLong { get; set; } public string Address { get; set; } = string.Empty; public string PostalCode { get; set; } = string.Empty; public string ReceiverPhoneNumber { get; set; } = string.Empty; public string ReceiverFullName { get; set; } = string.Empty; public string ShippingMethod { get; set; } = string.Empty; + public double DeliveryCost { get; internal set; } + public Guid AddressId { get; set; } public Guid OrderId { get; set; } public Guid ShippingId { get; internal set; } } diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs index 1255fe7..e28d1bd 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs @@ -8,4 +8,5 @@ public class ShippingSDto : BaseDto public bool IsShipBySeller { get; set; } public bool IsOriginalWarehouse { get; set; } public double DeliveryCost { get; set; } + public int WorkingDays { get; set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/UserAddressSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/UserAddressSDto.cs new file mode 100644 index 0000000..d667878 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/UserAddressSDto.cs @@ -0,0 +1,16 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class UserAddressSDto : BaseDto +{ + public string Address { get; set; } = string.Empty; + public string PostalCode { get; set; } = string.Empty; + public string ReceiverFullName { get; set; } = string.Empty; + public string ReceiverPhoneNumber { get; set; } = string.Empty; + public float LocationLat { get; set; } + public float LocationLong { get; set; } + public string Province { get; set; } = string.Empty; + public string City { get; set; } = string.Empty; + public string Plaque { get; set; } = string.Empty; + public string BuildingUnit { get; set; } = string.Empty; + public Guid UserId { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs b/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs index 3579af2..53a25ce 100644 --- a/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs @@ -72,9 +72,9 @@ public partial class Order } } - public void AddOrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId) + public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId) { - var orderDelivery = OrderDelivery.Create(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId); + var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId); OrderDeliveries.Add(orderDelivery); } @@ -122,8 +122,8 @@ public partial class OrderProduct public partial class OrderDelivery { - public static OrderDelivery Create(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId) + public static OrderDelivery Create(Guid addressId,double deliveryCost, Guid shippingId, Guid orderId) { - return new OrderDelivery(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId); + return new OrderDelivery(addressId, deliveryCost, shippingId, orderId); } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs b/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs index b9ba396..b14f627 100644 --- a/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs +++ b/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs @@ -6,20 +6,17 @@ public partial class OrderDelivery : ApiEntity { } - public OrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId) + public OrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId) { - Address = address; - PostalCode = postalCode; - ReceiverPhoneNumber = receiverPhoneNumber; - ReceiverFullName = receiverFullName; + AddressId = addressId; DeliveryCost = deliveryCost; ShippingId = shippingId; OrderId = orderId; } - public string Address { get; internal set; } = string.Empty; - public string PostalCode { get; internal set; } = string.Empty; - public string ReceiverPhoneNumber { get; internal set; } = string.Empty; - public string ReceiverFullName { get; internal set; } = string.Empty; + + public Guid AddressId { get; set; } + public UserAddress? Address { get; set; } + public double DeliveryCost { get; internal set; } public Guid ShippingId { get; internal set; } public Shipping? Shipping { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Pages/BasePageEntity.cs b/NetinaShop.Domain/Entities/Pages/BasePageEntity.cs new file mode 100644 index 0000000..edc8b37 --- /dev/null +++ b/NetinaShop.Domain/Entities/Pages/BasePageEntity.cs @@ -0,0 +1,14 @@ +namespace NetinaShop.Domain.Entities.Pages; + +public class BasePageEntity +{ + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public bool IsCustomPage { get; set; } + public bool IsHtmlBasePage { get; set; } + public string Slug { get; set; } = string.Empty; + public string Type { get; set; } = string.Empty; + public string Data { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Pages/FAQPage.cs b/NetinaShop.Domain/Entities/Pages/FAQPage.cs new file mode 100644 index 0000000..d8dd156 --- /dev/null +++ b/NetinaShop.Domain/Entities/Pages/FAQPage.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Domain.Entities.Pages; + +[PageClassDisplay("FAQPage", "صفحه سوالات متداول")] +public class FAQPage +{ + public Dictionary Faqs { get; set; } = new Dictionary(); +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Settings/PaymentSetting.cs b/NetinaShop.Domain/Entities/Settings/PaymentSetting.cs new file mode 100644 index 0000000..b7bf677 --- /dev/null +++ b/NetinaShop.Domain/Entities/Settings/PaymentSetting.cs @@ -0,0 +1,9 @@ +namespace NetinaShop.Domain.Entities.Settings; + +public class PaymentSetting +{ + public Guid Id { get; set; } + public string ZarinPalApiKey { get; set; } = string.Empty; + public string PayPalApiKey { get; set; } = string.Empty; + public string BehPardakhtApiKey { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Users/User.Aggreage.cs b/NetinaShop.Domain/Entities/Users/User.Aggreage.cs new file mode 100644 index 0000000..fd166fa --- /dev/null +++ b/NetinaShop.Domain/Entities/Users/User.Aggreage.cs @@ -0,0 +1,13 @@ +namespace NetinaShop.Domain.Entities.Users; + +public partial class UserAddress +{ + public static UserAddress Create(string address, string postalCode, string receiverFullName, + string receiverPhoneNumber, float locationLat, float locationLong, string province, string city, string plaque, + string buildingUnit, Guid userId) + { + return new UserAddress(address, postalCode, receiverFullName, receiverPhoneNumber, + locationLat, locationLong, province, city, plaque, buildingUnit, + userId); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Users/UserAddress.cs b/NetinaShop.Domain/Entities/Users/UserAddress.cs index 84d8010..f7d3fda 100644 --- a/NetinaShop.Domain/Entities/Users/UserAddress.cs +++ b/NetinaShop.Domain/Entities/Users/UserAddress.cs @@ -1,13 +1,42 @@ namespace NetinaShop.Domain.Entities.Users; -public class UserAddress : ApiEntity +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class UserAddress : ApiEntity { + public UserAddress() + { + + } + + public UserAddress(string address, string postalCode, string receiverFullName, string receiverPhoneNumber, + float locationLat, float locationLong, string province, string city, string plaque, string buildingUnit, + Guid userId) + { + Address = address; + PostalCode = postalCode; + ReceiverFullName = receiverFullName; + ReceiverPhoneNumber = receiverPhoneNumber; + LocationLat = locationLat; + LocationLong = locationLong; + Province = province; + City = city; + Plaque = plaque; + BuildingUnit = buildingUnit; + UserId = userId; + } + public string Address { get; internal set; } = string.Empty; public string PostalCode { get; internal set; } = string.Empty; public string ReceiverFullName { get; internal set; } = string.Empty; public string ReceiverPhoneNumber { get; internal set; } = string.Empty; public float LocationLat { get; internal set; } public float LocationLong { get; internal set; } + public string Province { get; internal set; } = string.Empty; + public string City { get; internal set; } = string.Empty; + public string Plaque { get; internal set; } = string.Empty; + public string BuildingUnit { get; internal set; } = string.Empty; public Guid UserId { get; internal set; } public ApplicationUser? User { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Warehouses/Shipping.cs b/NetinaShop.Domain/Entities/Warehouses/Shipping.cs index 341e96c..7829b27 100644 --- a/NetinaShop.Domain/Entities/Warehouses/Shipping.cs +++ b/NetinaShop.Domain/Entities/Warehouses/Shipping.cs @@ -9,7 +9,7 @@ public partial class Shipping : ApiEntity { } - public Shipping(string name, string warehouseName, bool isExpressShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost) + public Shipping(string name, string warehouseName, bool isExpressShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost, int workingDays) { Name = name; WarehouseName = warehouseName; @@ -17,6 +17,7 @@ public partial class Shipping : ApiEntity IsShipBySeller = isShipBySeller; IsOriginalWarehouse = isOriginalWarehouse; DeliveryCost = deliveryCost; + WorkingDays = workingDays; } public string Name { get; internal set; } = string.Empty; @@ -25,4 +26,5 @@ public partial class Shipping : ApiEntity public bool IsShipBySeller { get; internal set; } public bool IsOriginalWarehouse { get; internal set; } public double DeliveryCost { get; internal set; } + public int WorkingDays { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs b/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs index eec54dc..ce9ceee 100644 --- a/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs @@ -7,8 +7,8 @@ public partial class Warehouses public partial class Shipping { - public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost) + public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost,int workingDays) { - return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse,deliveryCost); + return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse,deliveryCost, workingDays); } } \ No newline at end of file diff --git a/NetinaShop.Domain/Enums/OrderPaymentMethod.cs b/NetinaShop.Domain/Enums/OrderPaymentMethod.cs index 9e8f652..cea6cbe 100644 --- a/NetinaShop.Domain/Enums/OrderPaymentMethod.cs +++ b/NetinaShop.Domain/Enums/OrderPaymentMethod.cs @@ -7,5 +7,7 @@ public enum OrderPaymentMethod [Display(Name = "پرداخت انلاین")] OnlinePayment, [Display(Name = "پرداخت کارت به کارت")] - CardTransfer + CardTransfer, + [Display(Name = "نقدی")] + Cash, } \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/OrderMapper.g.cs b/NetinaShop.Domain/Mappers/OrderMapper.g.cs index 4f1b862..cfa471b 100644 --- a/NetinaShop.Domain/Mappers/OrderMapper.g.cs +++ b/NetinaShop.Domain/Mappers/OrderMapper.g.cs @@ -112,10 +112,7 @@ namespace NetinaShop.Domain.Mappers }).ToList(), OrderDeliveries = p15.OrderDeliveries.Select(p17 => new OrderDelivery() { - Address = p17.Address, - PostalCode = p17.PostalCode, - ReceiverPhoneNumber = p17.ReceiverPhoneNumber, - ReceiverFullName = p17.ReceiverFullName, + Address = p17.Address == null ? null : (UserAddress)Convert.ChangeType((object)p17.Address, typeof(UserAddress)), ShippingId = p17.ShippingId, Shipping = new Shipping() {Id = p17.ShippingId}, OrderId = p17.OrderId, @@ -242,10 +239,7 @@ namespace NetinaShop.Domain.Mappers }).ToList(), OrderDeliveries = p31.OrderDeliveries.Select(p33 => new OrderDeliverySDto() { - Address = p33.Address, - PostalCode = p33.PostalCode, - ReceiverPhoneNumber = p33.ReceiverPhoneNumber, - ReceiverFullName = p33.ReceiverFullName, + Address = p33.Address == null ? null : p33.Address.ToString(), ShippingMethod = p33.Shipping != null ? p33.Shipping.Name : string.Empty, OrderId = p33.OrderId, ShippingId = p33.ShippingId, @@ -469,10 +463,7 @@ namespace NetinaShop.Domain.Mappers OrderDeliverySDto item = p3[i]; result.Add(item == null ? null : new OrderDelivery() { - Address = item.Address, - PostalCode = item.PostalCode, - ReceiverPhoneNumber = item.ReceiverPhoneNumber, - ReceiverFullName = item.ReceiverFullName, + Address = item.Address == null ? null : (UserAddress)Convert.ChangeType((object)item.Address, typeof(UserAddress)), ShippingId = item.ShippingId, Shipping = new Shipping() {Id = item.ShippingId}, OrderId = item.OrderId, @@ -593,10 +584,7 @@ namespace NetinaShop.Domain.Mappers OrderDeliverySDto item = p11[i]; result.Add(item == null ? null : new OrderDelivery() { - Address = item.Address, - PostalCode = item.PostalCode, - ReceiverPhoneNumber = item.ReceiverPhoneNumber, - ReceiverFullName = item.ReceiverFullName, + Address = item.Address == null ? null : (UserAddress)Convert.ChangeType((object)item.Address, typeof(UserAddress)), ShippingId = item.ShippingId, Shipping = new Shipping() {Id = item.ShippingId}, OrderId = item.OrderId, @@ -703,10 +691,7 @@ namespace NetinaShop.Domain.Mappers OrderDelivery item = p21[i]; result.Add(item == null ? null : new OrderDeliverySDto() { - Address = item.Address, - PostalCode = item.PostalCode, - ReceiverPhoneNumber = item.ReceiverPhoneNumber, - ReceiverFullName = item.ReceiverFullName, + Address = item.Address == null ? null : item.Address.ToString(), ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty, OrderId = item.OrderId, ShippingId = item.ShippingId, @@ -808,10 +793,7 @@ namespace NetinaShop.Domain.Mappers OrderDelivery item = p27[i]; result.Add(item == null ? null : new OrderDeliverySDto() { - Address = item.Address, - PostalCode = item.PostalCode, - ReceiverPhoneNumber = item.ReceiverPhoneNumber, - ReceiverFullName = item.ReceiverFullName, + Address = item.Address == null ? null : item.Address.ToString(), ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty, OrderId = item.OrderId, ShippingId = item.ShippingId, diff --git a/NetinaShop.Domain/Mappers/ShippingMapper.g.cs b/NetinaShop.Domain/Mappers/ShippingMapper.g.cs index 04569e6..bab358c 100644 --- a/NetinaShop.Domain/Mappers/ShippingMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ShippingMapper.g.cs @@ -17,6 +17,7 @@ namespace NetinaShop.Domain.Mappers IsShipBySeller = p1.IsShipBySeller, IsOriginalWarehouse = p1.IsOriginalWarehouse, DeliveryCost = p1.DeliveryCost, + WorkingDays = p1.WorkingDays, Id = p1.Id, CreatedAt = p1.CreatedAt }; @@ -35,6 +36,7 @@ namespace NetinaShop.Domain.Mappers result.IsShipBySeller = p2.IsShipBySeller; result.IsOriginalWarehouse = p2.IsOriginalWarehouse; result.DeliveryCost = p2.DeliveryCost; + result.WorkingDays = p2.WorkingDays; result.Id = p2.Id; result.CreatedAt = p2.CreatedAt; return result; @@ -50,6 +52,7 @@ namespace NetinaShop.Domain.Mappers IsShipBySeller = p4.IsShipBySeller, IsOriginalWarehouse = p4.IsOriginalWarehouse, DeliveryCost = p4.DeliveryCost, + WorkingDays = p4.WorkingDays, Id = p4.Id, CreatedAt = p4.CreatedAt }; @@ -68,6 +71,7 @@ namespace NetinaShop.Domain.Mappers result.IsShipBySeller = p5.IsShipBySeller; result.IsOriginalWarehouse = p5.IsOriginalWarehouse; result.DeliveryCost = p5.DeliveryCost; + result.WorkingDays = p5.WorkingDays; result.Id = p5.Id; result.CreatedAt = p5.CreatedAt; return result; @@ -81,6 +85,7 @@ namespace NetinaShop.Domain.Mappers IsShipBySeller = p7.IsShipBySeller, IsOriginalWarehouse = p7.IsOriginalWarehouse, DeliveryCost = p7.DeliveryCost, + WorkingDays = p7.WorkingDays, Id = p7.Id, CreatedAt = p7.CreatedAt }; diff --git a/NetinaShop.Domain/Mappers/UserAddressMapper.g.cs b/NetinaShop.Domain/Mappers/UserAddressMapper.g.cs new file mode 100644 index 0000000..f9c2ab4 --- /dev/null +++ b/NetinaShop.Domain/Mappers/UserAddressMapper.g.cs @@ -0,0 +1,113 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Users; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class UserAddressMapper + { + public static UserAddress AdaptToUserAddress(this UserAddressSDto p1) + { + return p1 == null ? null : new UserAddress() + { + Address = p1.Address, + PostalCode = p1.PostalCode, + ReceiverFullName = p1.ReceiverFullName, + ReceiverPhoneNumber = p1.ReceiverPhoneNumber, + LocationLat = p1.LocationLat, + LocationLong = p1.LocationLong, + Province = p1.Province, + City = p1.City, + Plaque = p1.Plaque, + BuildingUnit = p1.BuildingUnit, + UserId = p1.UserId, + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static UserAddress AdaptTo(this UserAddressSDto p2, UserAddress p3) + { + if (p2 == null) + { + return null; + } + UserAddress result = p3 ?? new UserAddress(); + + result.Address = p2.Address; + result.PostalCode = p2.PostalCode; + result.ReceiverFullName = p2.ReceiverFullName; + result.ReceiverPhoneNumber = p2.ReceiverPhoneNumber; + result.LocationLat = p2.LocationLat; + result.LocationLong = p2.LocationLong; + result.Province = p2.Province; + result.City = p2.City; + result.Plaque = p2.Plaque; + result.BuildingUnit = p2.BuildingUnit; + result.UserId = p2.UserId; + result.Id = p2.Id; + result.CreatedAt = p2.CreatedAt; + return result; + + } + public static UserAddressSDto AdaptToSDto(this UserAddress p4) + { + return p4 == null ? null : new UserAddressSDto() + { + Address = p4.Address, + PostalCode = p4.PostalCode, + ReceiverFullName = p4.ReceiverFullName, + ReceiverPhoneNumber = p4.ReceiverPhoneNumber, + LocationLat = p4.LocationLat, + LocationLong = p4.LocationLong, + Province = p4.Province, + City = p4.City, + Plaque = p4.Plaque, + BuildingUnit = p4.BuildingUnit, + UserId = p4.UserId, + Id = p4.Id, + CreatedAt = p4.CreatedAt + }; + } + public static UserAddressSDto AdaptTo(this UserAddress p5, UserAddressSDto p6) + { + if (p5 == null) + { + return null; + } + UserAddressSDto result = p6 ?? new UserAddressSDto(); + + result.Address = p5.Address; + result.PostalCode = p5.PostalCode; + result.ReceiverFullName = p5.ReceiverFullName; + result.ReceiverPhoneNumber = p5.ReceiverPhoneNumber; + result.LocationLat = p5.LocationLat; + result.LocationLong = p5.LocationLong; + result.Province = p5.Province; + result.City = p5.City; + result.Plaque = p5.Plaque; + result.BuildingUnit = p5.BuildingUnit; + result.UserId = p5.UserId; + result.Id = p5.Id; + result.CreatedAt = p5.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p7 => new UserAddressSDto() + { + Address = p7.Address, + PostalCode = p7.PostalCode, + ReceiverFullName = p7.ReceiverFullName, + ReceiverPhoneNumber = p7.ReceiverPhoneNumber, + LocationLat = p7.LocationLat, + LocationLong = p7.LocationLong, + Province = p7.Province, + City = p7.City, + Plaque = p7.Plaque, + BuildingUnit = p7.BuildingUnit, + UserId = p7.UserId, + Id = p7.Id, + CreatedAt = p7.CreatedAt + }; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs b/NetinaShop.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs index 0f55141..7fb5682 100644 --- a/NetinaShop.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs +++ b/NetinaShop.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs @@ -1,4 +1,7 @@ -namespace NetinaShop.Repository.Extensions; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; + +namespace NetinaShop.Repository.Extensions; public class DbContextOptionCustomExtensionsInfo : DbContextOptionsExtensionInfo { diff --git a/NetinaShop.Repository/Extensions/ModelBuilderExtensions.cs b/NetinaShop.Repository/Extensions/ModelBuilderExtensions.cs index 6ddf37a..596495c 100644 --- a/NetinaShop.Repository/Extensions/ModelBuilderExtensions.cs +++ b/NetinaShop.Repository/Extensions/ModelBuilderExtensions.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Extensions; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Extensions; public class ModelBuilderQueryFilter { diff --git a/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs b/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs index a84de88..00e58d5 100644 --- a/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Accounting; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Accounting; namespace NetinaShop.Repository.Handlers.Accounting; diff --git a/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs b/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs index 1fa3cac..5bafe3e 100644 --- a/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Accounting; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Accounting; namespace NetinaShop.Repository.Handlers.Accounting; diff --git a/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs b/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs index 1485d9c..37df2d7 100644 --- a/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Accounting; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Accounting; namespace NetinaShop.Repository.Handlers.Accounting; diff --git a/NetinaShop.Repository/Handlers/Addresses/CreateAddressCommandHandler.cs b/NetinaShop.Repository/Handlers/Addresses/CreateAddressCommandHandler.cs new file mode 100644 index 0000000..d297889 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Addresses/CreateAddressCommandHandler.cs @@ -0,0 +1,28 @@ +namespace NetinaShop.Repository.Handlers.Addresses; + +public class CreateAddressCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + + public CreateAddressCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) + { + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + } + public async Task Handle(CreateAddressCommand request, CancellationToken cancellationToken) + { + if (_currentUserService.UserId == null) + throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + + var ent = UserAddress.Create(request.Address, request.PostalCode, request.ReceiverFullName, + request.ReceiverPhoneNumber, request.LocationLat, request.LocationLong, request.Province, request.City, + request.Plaque, request.BuildingUnit, userId); + + _repositoryWrapper.SetRepository().Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return false; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Addresses/DeleteAddressCommandHandler.cs b/NetinaShop.Repository/Handlers/Addresses/DeleteAddressCommandHandler.cs new file mode 100644 index 0000000..41d4ba2 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Addresses/DeleteAddressCommandHandler.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Addresses; + +public class DeleteAddressCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteAddressCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteAddressCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(u => u.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Address not found", ApiResultStatusCode.NotFound); + _repositoryWrapper.SetRepository() + .Delete(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Addresses/GetUserAddressesQueryHandler.cs b/NetinaShop.Repository/Handlers/Addresses/GetUserAddressesQueryHandler.cs new file mode 100644 index 0000000..4a2584c --- /dev/null +++ b/NetinaShop.Repository/Handlers/Addresses/GetUserAddressesQueryHandler.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Addresses; + +public class GetUserAddressesQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + + public GetUserAddressesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) + { + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + } + public async Task> Handle(GetUserAddressesQuery request, CancellationToken cancellationToken) + { + Guid userId; + if (request.UserId != null) + userId = request.UserId.Value; + else + { + if (_currentUserService.UserId == null) + throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + if (!Guid.TryParse(_currentUserService.UserId, out userId)) + throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + } + + return await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(ua => ua.UserId == userId) + .Select(UserAddressMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Brands/DeleteBrandCommandHandler.cs b/NetinaShop.Repository/Handlers/Brands/DeleteBrandCommandHandler.cs index 0e06e88..ed7f755 100644 --- a/NetinaShop.Repository/Handlers/Brands/DeleteBrandCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Brands/DeleteBrandCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Brands; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Brands; namespace NetinaShop.Repository.Handlers.Brands; diff --git a/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs b/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs index 56e7340..7b3810c 100644 --- a/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Brands; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Brands; namespace NetinaShop.Repository.Handlers.Brands; diff --git a/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs b/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs index d876d4f..e84c406 100644 --- a/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Brands; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Brands; namespace NetinaShop.Repository.Handlers.Brands; diff --git a/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs index ce0a0b7..e308ace 100644 --- a/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Discounts; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Discounts; public class DeleteDiscountCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs b/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs index 4377a72..3bfb868 100644 --- a/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Discounts; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Discounts; public class GetDiscountQueryHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs b/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs index 15a4ed5..ed6825a 100644 --- a/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Discounts; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Discounts; public class GetDiscountsQueryHandler : IRequestHandler> { diff --git a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs index 0adc24c..9dea878 100644 --- a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Discounts; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Discounts; public class UpdateDiscountCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs b/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs index 9673252..d4f4def 100644 --- a/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Orders; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Orders; namespace NetinaShop.Repository.Handlers.Orders; diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs index f129a68..9626384 100644 --- a/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Orders; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Orders; namespace NetinaShop.Repository.Handlers.Orders; diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs index 610f903..dd4c43f 100644 --- a/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Orders; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Orders; namespace NetinaShop.Repository.Handlers.Orders; @@ -31,7 +32,7 @@ public class GetOrderQueryHandler : IRequestHandler .Where(od => od.OrderId == request.Id) .ToListAsync(cancellationToken); - orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.Address,od.PostalCode,od.ReceiverPhoneNumber,od.ReceiverFullName,od.DeliveryCost,od.ShippingId,od.OrderId)); + orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.AddressId,od.DeliveryCost,od.ShippingId,od.OrderId)); return order; } diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs index 0c62612..21208b6 100644 --- a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Orders; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Orders; namespace NetinaShop.Repository.Handlers.Orders; diff --git a/NetinaShop.Repository/Handlers/ProductCategories/DeleteProductCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/DeleteProductCategoryCommandHandler.cs index ca1551c..a48db71 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/DeleteProductCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/DeleteProductCategoryCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.ProductCategories; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.ProductCategories; namespace NetinaShop.Repository.Handlers.ProductCategories; diff --git a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs index b99bf7e..7d7df29 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoriesQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.ProductCategories; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.ProductCategories; namespace NetinaShop.Repository.Handlers.ProductCategories; diff --git a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryChildrenQueryHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryChildrenQueryHandler.cs index 18da4d6..737dee1 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryChildrenQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryChildrenQueryHandler.cs @@ -1,5 +1,6 @@ using MediatR; using System.Threading; +using Microsoft.EntityFrameworkCore; namespace NetinaShop.Repository.Handlers.ProductCategories; diff --git a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryQueryHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryQueryHandler.cs index 9be3c35..64e27c3 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/GetProductCategoryQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.ProductCategories; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.ProductCategories; namespace NetinaShop.Repository.Handlers.ProductCategories; diff --git a/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs index 31b8810..f2c179f 100644 --- a/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/ProductCategories/UpdateProductCategoryCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.ProductCategories; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.ProductCategories; namespace NetinaShop.Repository.Handlers.ProductCategories; diff --git a/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs index 50a66a3..d115981 100644 --- a/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Products; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Products; public class DeleteProductCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs b/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs index 07dbcfa..a3f1bef 100644 --- a/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Products; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Products; public class GetProductQueryHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs b/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs index 4fce9e1..77c58a6 100644 --- a/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Internal; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Internal; using NetinaShop.Domain.Dtos.LargDtos; using NetinaShop.Domain.Dtos.SmallDtos; diff --git a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs index 5193836..e768114 100644 --- a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Products; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Products; public class UpdateProductCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Reviews/CreateReviewCommandHandler.cs b/NetinaShop.Repository/Handlers/Reviews/CreateReviewCommandHandler.cs index 16ff545..3823fec 100644 --- a/NetinaShop.Repository/Handlers/Reviews/CreateReviewCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Reviews/CreateReviewCommandHandler.cs @@ -1,4 +1,5 @@ -using AppException = NetinaShop.Common.Models.Exception.AppException; +using Microsoft.EntityFrameworkCore; +using AppException = NetinaShop.Common.Models.Exception.AppException; namespace NetinaShop.Repository.Handlers.Reviews; diff --git a/NetinaShop.Repository/Handlers/Reviews/DeleteReviewCommandHandler.cs b/NetinaShop.Repository/Handlers/Reviews/DeleteReviewCommandHandler.cs index e838605..8e6c97c 100644 --- a/NetinaShop.Repository/Handlers/Reviews/DeleteReviewCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Reviews/DeleteReviewCommandHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Reviews; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Reviews; public class DeleteReviewCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Reviews/GetReviewQueryHandler.cs b/NetinaShop.Repository/Handlers/Reviews/GetReviewQueryHandler.cs index 85d018e..166d488 100644 --- a/NetinaShop.Repository/Handlers/Reviews/GetReviewQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Reviews/GetReviewQueryHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Reviews; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Reviews; public class GetReviewQueryHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Reviews/GetReviewsQueryHandler.cs b/NetinaShop.Repository/Handlers/Reviews/GetReviewsQueryHandler.cs index bbb646e..930eb40 100644 --- a/NetinaShop.Repository/Handlers/Reviews/GetReviewsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Reviews/GetReviewsQueryHandler.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Handlers.Reviews; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Reviews; public class GetReviewsQueryHandler : IRequestHandler> { diff --git a/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs index f645acd..933eb3e 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs @@ -13,7 +13,7 @@ public class CreateShippingCommandHandler : IRequestHandler Handle(CreateShippingCommand request, CancellationToken cancellationToken) { var ent = Shipping.Create(request.Name, request.WarehouseName, request.IsExpressShipping, request.IsShipBySeller, - request.IsOriginalWarehouse,request.DeliveryCost); + request.IsOriginalWarehouse,request.DeliveryCost,request.WorkingDays); _repositoryWrapper.SetRepository().Add(ent); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return ent.AdaptToSDto(); diff --git a/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs index 3be1018..556eb8e 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Warehouses; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Warehouses; namespace NetinaShop.Repository.Handlers.Warehouses; diff --git a/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs index 2950bbf..1001e0b 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Warehouses; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Warehouses; namespace NetinaShop.Repository.Handlers.Warehouses; diff --git a/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs index 10a94a4..305a751 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Warehouses; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Warehouses; namespace NetinaShop.Repository.Handlers.Warehouses; diff --git a/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs index f6bb642..5c05213 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Warehouses; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Warehouses; namespace NetinaShop.Repository.Handlers.Warehouses; @@ -18,7 +19,7 @@ public class UpdateShippingCommandHandler : IRequestHandler +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("20240212114249_EditAddress")] + partial class EditAddress + { + /// + 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("HasSpecialPage") + .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("PageUrl") + .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("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("IsForInvitation") + .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.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("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + 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("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("Address") + .IsRequired() + .HasColumnType("text"); + + 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("PostalCode") + .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("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + 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("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.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.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.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.Orders.Order", "Order") + .WithMany("OrderDeliveries") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + 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("OrderDeliveries"); + + 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/20240212114249_EditAddress.cs b/NetinaShop.Repository/Migrations/20240212114249_EditAddress.cs new file mode 100644 index 0000000..59c8aa7 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240212114249_EditAddress.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditAddress : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "BuildingUnit", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "City", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Plaque", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "Province", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "BuildingUnit", + schema: "public", + table: "UserAddresses"); + + migrationBuilder.DropColumn( + name: "City", + schema: "public", + table: "UserAddresses"); + + migrationBuilder.DropColumn( + name: "Plaque", + schema: "public", + table: "UserAddresses"); + + migrationBuilder.DropColumn( + name: "Province", + schema: "public", + table: "UserAddresses"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.Designer.cs b/NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.Designer.cs new file mode 100644 index 0000000..1b01a7b --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.Designer.cs @@ -0,0 +1,1682 @@ +// +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("20240212160400_EditShippingAddWorkingDays")] + partial class EditShippingAddWorkingDays + { + /// + 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("HasSpecialPage") + .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("PageUrl") + .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("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("IsForInvitation") + .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.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("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + 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("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("Address") + .IsRequired() + .HasColumnType("text"); + + 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("PostalCode") + .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("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + 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("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.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.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.Orders.Order", "Order") + .WithMany("OrderDeliveries") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + 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("OrderDeliveries"); + + 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/20240212160400_EditShippingAddWorkingDays.cs b/NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.cs new file mode 100644 index 0000000..5f50f9c --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240212160400_EditShippingAddWorkingDays.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditShippingAddWorkingDays : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "WorkingDays", + schema: "public", + table: "Shippings", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "WorkingDays", + schema: "public", + table: "Shippings"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.Designer.cs b/NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.Designer.cs new file mode 100644 index 0000000..0721b13 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.Designer.cs @@ -0,0 +1,1678 @@ +// +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("20240212172112_EditShippingAddAddressId")] + partial class EditShippingAddAddressId + { + /// + 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("HasSpecialPage") + .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("PageUrl") + .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("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("IsForInvitation") + .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.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("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + 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("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"); + + 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("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.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.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") + .WithMany("OrderDeliveries") + .HasForeignKey("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("OrderDeliveries"); + + 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/20240212172112_EditShippingAddAddressId.cs b/NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.cs new file mode 100644 index 0000000..ae25272 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240212172112_EditShippingAddAddressId.cs @@ -0,0 +1,110 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditShippingAddAddressId : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Address", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.DropColumn( + name: "PostalCode", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.DropColumn( + name: "ReceiverFullName", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.DropColumn( + name: "ReceiverPhoneNumber", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.AddColumn( + name: "AddressId", + schema: "public", + table: "OrderDeliveries", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.CreateIndex( + name: "IX_OrderDeliveries_AddressId", + schema: "public", + table: "OrderDeliveries", + column: "AddressId"); + + migrationBuilder.AddForeignKey( + name: "FK_OrderDeliveries_UserAddresses_AddressId", + schema: "public", + table: "OrderDeliveries", + column: "AddressId", + principalSchema: "public", + principalTable: "UserAddresses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_OrderDeliveries_UserAddresses_AddressId", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.DropIndex( + name: "IX_OrderDeliveries_AddressId", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.DropColumn( + name: "AddressId", + schema: "public", + table: "OrderDeliveries"); + + migrationBuilder.AddColumn( + name: "Address", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "PostalCode", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "ReceiverFullName", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "ReceiverPhoneNumber", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: ""); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index 448b5f6..0708b2e 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -534,9 +534,8 @@ namespace NetinaShop.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("Address") - .IsRequired() - .HasColumnType("text"); + b.Property("AddressId") + .HasColumnType("uuid"); b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -559,18 +558,6 @@ namespace NetinaShop.Repository.Migrations b.Property("OrderId") .HasColumnType("uuid"); - b.Property("PostalCode") - .IsRequired() - .HasColumnType("text"); - - b.Property("ReceiverFullName") - .IsRequired() - .HasColumnType("text"); - - b.Property("ReceiverPhoneNumber") - .IsRequired() - .HasColumnType("text"); - b.Property("RemovedAt") .HasColumnType("timestamp without time zone"); @@ -582,6 +569,8 @@ namespace NetinaShop.Repository.Migrations b.HasKey("Id"); + b.HasIndex("AddressId"); + b.HasIndex("OrderId"); b.HasIndex("ShippingId"); @@ -1115,6 +1104,14 @@ namespace NetinaShop.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("BuildingUnit") + .IsRequired() + .HasColumnType("text"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -1136,10 +1133,18 @@ namespace NetinaShop.Repository.Migrations 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"); @@ -1253,6 +1258,9 @@ namespace NetinaShop.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("WorkingDays") + .HasColumnType("integer"); + b.HasKey("Id"); b.ToTable("Shippings", "public"); @@ -1418,6 +1426,11 @@ namespace NetinaShop.Repository.Migrations modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => { + b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") .WithMany("OrderDeliveries") .HasForeignKey("OrderId") @@ -1428,6 +1441,8 @@ namespace NetinaShop.Repository.Migrations .HasForeignKey("ShippingId") .OnDelete(DeleteBehavior.Restrict); + b.Navigation("Address"); + b.Navigation("Order"); b.Navigation("Shipping"); diff --git a/NetinaShop.Repository/Models/ApplicationContext.cs b/NetinaShop.Repository/Models/ApplicationContext.cs index be03815..a8c06db 100644 --- a/NetinaShop.Repository/Models/ApplicationContext.cs +++ b/NetinaShop.Repository/Models/ApplicationContext.cs @@ -1,4 +1,7 @@ -namespace NetinaShop.Repository.Models; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Models; public class ApplicationContext : IdentityDbContext diff --git a/NetinaShop.Repository/NetinaShop.Repository.csproj b/NetinaShop.Repository/NetinaShop.Repository.csproj index 9a70b6f..d0657a5 100644 --- a/NetinaShop.Repository/NetinaShop.Repository.csproj +++ b/NetinaShop.Repository/NetinaShop.Repository.csproj @@ -8,6 +8,7 @@ + @@ -45,11 +46,6 @@ - - - - - diff --git a/NetinaShop.Repository/Repositories/Base/BaseRepository.cs b/NetinaShop.Repository/Repositories/Base/BaseRepository.cs index a3780ec..130c3bd 100644 --- a/NetinaShop.Repository/Repositories/Base/BaseRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/BaseRepository.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Repositories.Base +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Repositories.Base { public class BaseRepository : Repository, IBaseRepository where T : class, IApiEntity { diff --git a/NetinaShop.Repository/Repositories/Base/Contracts/IReadRepository.cs b/NetinaShop.Repository/Repositories/Base/Contracts/IReadRepository.cs index 73c4a19..3667a39 100644 --- a/NetinaShop.Repository/Repositories/Base/Contracts/IReadRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/Contracts/IReadRepository.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Repositories.Base.Contracts +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Repositories.Base.Contracts { public interface IReadRepository where T : class, IApiEntity { diff --git a/NetinaShop.Repository/Repositories/Base/Contracts/IRepository.cs b/NetinaShop.Repository/Repositories/Base/Contracts/IRepository.cs index 714439a..f499ad0 100644 --- a/NetinaShop.Repository/Repositories/Base/Contracts/IRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/Contracts/IRepository.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Repositories.Base.Contracts +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Repositories.Base.Contracts { internal interface IRepository where T : class, IApiEntity { diff --git a/NetinaShop.Repository/Repositories/Base/ReadRepository.cs b/NetinaShop.Repository/Repositories/Base/ReadRepository.cs index d9e716d..fb716d1 100644 --- a/NetinaShop.Repository/Repositories/Base/ReadRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/ReadRepository.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Repositories.Base +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Repositories.Base { public class ReadRepository : Repository, IDisposable, IReadRepository where T : class, IApiEntity { diff --git a/NetinaShop.Repository/Repositories/Base/Repository.cs b/NetinaShop.Repository/Repositories/Base/Repository.cs index df4f649..a020d12 100644 --- a/NetinaShop.Repository/Repositories/Base/Repository.cs +++ b/NetinaShop.Repository/Repositories/Base/Repository.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Repositories.Base +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Repositories.Base { public class Repository : IRepository where T : class, IApiEntity { diff --git a/NetinaShop.Repository/Repositories/Base/RepositoryWrapper.cs b/NetinaShop.Repository/Repositories/Base/RepositoryWrapper.cs index 9c95177..0e32c4a 100644 --- a/NetinaShop.Repository/Repositories/Base/RepositoryWrapper.cs +++ b/NetinaShop.Repository/Repositories/Base/RepositoryWrapper.cs @@ -1,4 +1,8 @@ -namespace NetinaShop.Repository.Repositories.Base; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.EntityFrameworkCore.Storage; + +namespace NetinaShop.Repository.Repositories.Base; public class RepositoryWrapper : IRepositoryWrapper { private readonly ApplicationContext _context; diff --git a/NetinaShop.Repository/Repositories/Base/WriteRepository.cs b/NetinaShop.Repository/Repositories/Base/WriteRepository.cs index 8dda98b..95dc025 100644 --- a/NetinaShop.Repository/Repositories/Base/WriteRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/WriteRepository.cs @@ -1,4 +1,6 @@  +using Microsoft.EntityFrameworkCore; + namespace NetinaShop.Repository.Repositories.Base { public class WriteRepository : Repository, IDisposable, IWriteRepository where T : class, IApiEntity diff --git a/NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs b/NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs deleted file mode 100644 index ee8f9e5..0000000 --- a/NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace NetinaShop.Repository.Repositories.Entity.Abstracts; - -public interface IDiscountRepository : IScopedDependency, IDisposable, IReadRepository, IWriteRepository -{ -} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/Abstracts/IMartenRepository.cs b/NetinaShop.Repository/Repositories/Entity/Abstracts/IMartenRepository.cs new file mode 100644 index 0000000..3824d24 --- /dev/null +++ b/NetinaShop.Repository/Repositories/Entity/Abstracts/IMartenRepository.cs @@ -0,0 +1,15 @@ +using System.Linq.Expressions; + +namespace NetinaShop.Repository.Repositories.Entity.Abstracts; + +public interface IMartenRepository : IScopedDependency +{ + Task> GetEntitiesAsync(CancellationToken cancellation) where TSetting : notnull; + Task> GetEntitiesAsync(Expression> expression,CancellationToken cancellation) where TSetting : notnull; + + Task GetEntityAsync(Guid id,CancellationToken cancellation) where TSetting : notnull; + Task GetEntityAsync(Expression> expression, CancellationToken cancellation) where TSetting : notnull; + + Task AddOrUpdateEntityAsync(TSetting setting, CancellationToken cancellation) where TSetting : notnull; + Task RemoveEntityAsync(CancellationToken cancellation); +} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs b/NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs deleted file mode 100644 index e57398f..0000000 --- a/NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace NetinaShop.Repository.Repositories.Entity.Abstracts; - -public interface IProductRepository : IScopedDependency , IDisposable, IReadRepository, IWriteRepository -{ - -} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs b/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs deleted file mode 100644 index f06e62d..0000000 --- a/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NetinaShop.Repository.Repositories.Entity; - -public class DiscountRepository : BaseRepository, IDiscountRepository -{ - - public DiscountRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService) - { - } -} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/MartenRepository.cs b/NetinaShop.Repository/Repositories/Entity/MartenRepository.cs new file mode 100644 index 0000000..eb13011 --- /dev/null +++ b/NetinaShop.Repository/Repositories/Entity/MartenRepository.cs @@ -0,0 +1,60 @@ +using System.Linq.Expressions; +using Marten; + +namespace NetinaShop.Repository.Repositories.Entity; + +public class MartenRepository : IMartenRepository +{ + private readonly IDocumentStore _documentStore; + + public MartenRepository(IDocumentStore documentStore) + { + _documentStore = documentStore; + } + public async Task> GetEntitiesAsync(CancellationToken cancellation) where TSetting : notnull + { + await using var session = _documentStore.QuerySession(); + var entities = await session.Query().ToListAsync(cancellation); + return entities.ToList(); + } + + public async Task> GetEntitiesAsync(Expression> expression, CancellationToken cancellation) where TSetting : notnull + { + await using var session = _documentStore.QuerySession(); + var entities = await session.Query().Where(expression).ToListAsync(cancellation); + return entities.ToList(); + } + + public async Task GetEntityAsync(Guid id,CancellationToken cancellation) where TSetting : notnull + { + await using var session = _documentStore.QuerySession(); + var setting = await session.LoadAsync(id,cancellation); + if (setting == null) + throw new AppException($"{nameof(setting)} not found", ApiResultStatusCode.NotFound); + return setting; + } + + public async Task GetEntityAsync(Expression> expression, CancellationToken cancellation) where TSetting : notnull + { + await using var session = _documentStore.QuerySession(); + var entity = await session.Query().FirstOrDefaultAsync(expression,cancellation); + if (entity == null) + throw new AppException($"{nameof(entity)} not found", ApiResultStatusCode.NotFound); + return entity; + } + + public async Task AddOrUpdateEntityAsync(TSetting setting, CancellationToken cancellation) where TSetting : notnull + { + if (setting == null) + throw new AppException($"{nameof(setting)} is null", ApiResultStatusCode.BadRequest); + + await using var session = _documentStore.LightweightSession(); + session.Store(setting); + await session.SaveChangesAsync(cancellation); + } + + public Task RemoveEntityAsync(CancellationToken cancellation) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/ProductRepository.cs b/NetinaShop.Repository/Repositories/Entity/ProductRepository.cs deleted file mode 100644 index cd925ae..0000000 --- a/NetinaShop.Repository/Repositories/Entity/ProductRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace NetinaShop.Repository.Repositories.Entity; - -public class ProductRepository : BaseRepository, IProductRepository -{ - - public ProductRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService) - { - - } - -} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/UnitOfWork/UnitOfWork.cs b/NetinaShop.Repository/Repositories/UnitOfWork/UnitOfWork.cs index a9395fa..c26a9aa 100644 --- a/NetinaShop.Repository/Repositories/UnitOfWork/UnitOfWork.cs +++ b/NetinaShop.Repository/Repositories/UnitOfWork/UnitOfWork.cs @@ -1,4 +1,8 @@ -namespace NetinaShop.Repository.Repositories.UnitOfWork; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.EntityFrameworkCore.Storage; + +namespace NetinaShop.Repository.Repositories.UnitOfWork; public class UnitOfWork : IUnitOfWork { diff --git a/NetinaShop.Repository/Services/DbInitializerService.cs b/NetinaShop.Repository/Services/DbInitializerService.cs index 7a5e0a6..b3b2872 100644 --- a/NetinaShop.Repository/Services/DbInitializerService.cs +++ b/NetinaShop.Repository/Services/DbInitializerService.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Repository.Services; +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Services; public class DbInitializerService : IDbInitializerService