diff --git a/NetinaShop.Api/Controller/BlogCategoryController.cs b/NetinaShop.Api/Controller/BlogCategoryController.cs index f4a117c..5d9a6fe 100644 --- a/NetinaShop.Api/Controller/BlogCategoryController.cs +++ b/NetinaShop.Api/Controller/BlogCategoryController.cs @@ -19,15 +19,15 @@ public class BlogCategoryController : ICarterModule .HasApiVersion(1.0); group.MapPost("", Post) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission,ApplicationPermission.ManageBlogs)) .HasApiVersion(1.0); group.MapPut("", Put) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/BlogController.cs b/NetinaShop.Api/Controller/BlogController.cs index 0fe0784..8dc354d 100644 --- a/NetinaShop.Api/Controller/BlogController.cs +++ b/NetinaShop.Api/Controller/BlogController.cs @@ -19,15 +19,15 @@ public class BlogController : ICarterModule .HasApiVersion(1.0); group.MapPost("", Post) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) .HasApiVersion(1.0); group.MapPut("", Put) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBlogs)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/BrandController.cs b/NetinaShop.Api/Controller/BrandController.cs index ab9dc1f..b24cab8 100644 --- a/NetinaShop.Api/Controller/BrandController.cs +++ b/NetinaShop.Api/Controller/BrandController.cs @@ -20,15 +20,15 @@ public class BrandController : ICarterModule group.MapPost("", Post) .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBrands)); group.MapPut("", Put) .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBrands)); group.MapDelete("{id}", Delete) .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageBrands)); } // GET:Get All Entity diff --git a/NetinaShop.Api/Controller/DashboardController.cs b/NetinaShop.Api/Controller/DashboardController.cs index cccdc41..6639fea 100644 --- a/NetinaShop.Api/Controller/DashboardController.cs +++ b/NetinaShop.Api/Controller/DashboardController.cs @@ -6,7 +6,7 @@ public class DashboardController : ICarterModule { var group = app.NewVersionedApi("Dashboard") .MapGroup("api/dashboard") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard)); group.MapGet("home", GetHomeDashboardAsync) .WithDisplayName("Get Home Dashboard") diff --git a/NetinaShop.Api/Controller/DiscountController.cs b/NetinaShop.Api/Controller/DiscountController.cs index 00171e5..974e689 100644 --- a/NetinaShop.Api/Controller/DiscountController.cs +++ b/NetinaShop.Api/Controller/DiscountController.cs @@ -10,10 +10,12 @@ public class DiscountController : ICarterModule group.MapGet("", GetAllAsync) .WithDisplayName("GetAllDiscounts") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard,ApplicationPermission.ViewDiscounts)) .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) .WithDisplayName("GetDiscount") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard, ApplicationPermission.ViewDiscounts)) .HasApiVersion(1.0); group.MapGet("corporate", GetCorporateDiscountAsync) @@ -21,13 +23,16 @@ public class DiscountController : ICarterModule .HasApiVersion(1.0); group.MapPost("", Post) - .HasApiVersion(1.0); + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard)); group.MapPut("", Put) - .HasApiVersion(1.0); + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard)); group.MapDelete("{id}", Delete) - .HasApiVersion(1.0); + .HasApiVersion(1.0) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard)); } private async Task GetCorporateDiscountAsync([FromQuery] Guid? corporateUserId, [FromServices] IMediator mediator, CancellationToken cancellationToken) diff --git a/NetinaShop.Api/Controller/FileController.cs b/NetinaShop.Api/Controller/FileController.cs index b5a9771..38e96b7 100644 --- a/NetinaShop.Api/Controller/FileController.cs +++ b/NetinaShop.Api/Controller/FileController.cs @@ -12,10 +12,12 @@ public class FileController : ICarterModule group.MapGet("", GetFilesAsync) .WithDisplayName("GetFilesAsync") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageFiles, ApplicationPermission.ViewFiles)) .HasApiVersion(1.0); group.MapPost("", UploadFileAsync) .WithDisplayName("UploadFileAsync") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageFiles)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/NewsletterMemberController.cs b/NetinaShop.Api/Controller/NewsletterMemberController.cs index 7e35008..1ff3f98 100644 --- a/NetinaShop.Api/Controller/NewsletterMemberController.cs +++ b/NetinaShop.Api/Controller/NewsletterMemberController.cs @@ -9,7 +9,7 @@ public class NewsletterMemberController : ICarterModule group.MapGet("", GetAllMembersAsync) .WithDisplayName("Get All Members") .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewNewsletterMembers)); group.MapPost("", PostMemberAsync) .WithDisplayName("Post Member") diff --git a/NetinaShop.Api/Controller/OrderBagController.cs b/NetinaShop.Api/Controller/OrderBagController.cs index 4795ecb..0db42f6 100644 --- a/NetinaShop.Api/Controller/OrderBagController.cs +++ b/NetinaShop.Api/Controller/OrderBagController.cs @@ -8,7 +8,7 @@ public class OrderBagController : ICarterModule { var group = app.NewVersionedApi("OrderBag") .MapGroup("api/order/bag") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.CreateOrder)); group.MapGet("", GetUserCurrentOrderBagAsync) .WithDisplayName("GetUserCurrentOrderBag") diff --git a/NetinaShop.Api/Controller/OrderController.cs b/NetinaShop.Api/Controller/OrderController.cs index ed0656f..d46187b 100644 --- a/NetinaShop.Api/Controller/OrderController.cs +++ b/NetinaShop.Api/Controller/OrderController.cs @@ -11,22 +11,27 @@ public class OrderController : ICarterModule group.MapGet("", GetAllAsync) .WithDisplayName("GetAllOrders") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllOrders , ApplicationPermission.ManageOrders)) .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) .WithDisplayName("GetOneOrder") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllOrders, ApplicationPermission.ManageOrders)) .HasApiVersion(1.0); group.MapPost("{id}/confirm", ConfirmOrderStepAsync) .WithDisplayName("ConfirmOrderStep") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageOrders)) .HasApiVersion(1.0); group.MapDelete("{id}", DeleteAsync) .WithDisplayName("DeleteOneOrder") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageOrders)) .HasApiVersion(1.0); group.MapGet("{id}/invoice", GetOrderInvoiceAsync) .WithDisplayName("GetOrderInvoice") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageOrders)) .AllowAnonymous() .HasApiVersion(1.0); diff --git a/NetinaShop.Api/Controller/PageController.cs b/NetinaShop.Api/Controller/PageController.cs index 349821c..81a9ab1 100644 --- a/NetinaShop.Api/Controller/PageController.cs +++ b/NetinaShop.Api/Controller/PageController.cs @@ -10,18 +10,18 @@ public class PageController : ICarterModule group.MapGet("", GetPagesAsync) .WithDisplayName("Get Pages") .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewPages, ApplicationPermission.ManagePages)); group.MapGet("{id}", GetPageByIdAsync) .WithDisplayName("Get Page") .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewPages, ApplicationPermission.ManagePages)); group.MapGet("slug/{pageSlug}", GetPageAsync) .WithDisplayName("Get Page") .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewPages, ApplicationPermission.ManagePages)); group.MapGet("type/{type}", GetPageByTypeAsync) .WithDisplayName("Get Page") @@ -30,7 +30,7 @@ public class PageController : ICarterModule group.MapPost("", PostPageAsync) .WithDisplayName("Post Page") .HasApiVersion(1.0) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManagePages)); } public async Task GetPagesAsync(Guid id, [FromServices] IPageService pageService, CancellationToken cancellationToken) { diff --git a/NetinaShop.Api/Controller/PaymentController.cs b/NetinaShop.Api/Controller/PaymentController.cs index bf18bfe..a290bc0 100644 --- a/NetinaShop.Api/Controller/PaymentController.cs +++ b/NetinaShop.Api/Controller/PaymentController.cs @@ -13,7 +13,7 @@ public class PaymentController : ICarterModule group.MapGet("", GetAllAsync) .WithDisplayName("GetPayments") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewPayments)) .HasApiVersion(1.0); //group.MapGet("{id}", GetAsync) diff --git a/NetinaShop.Api/Controller/ProductCategoryController.cs b/NetinaShop.Api/Controller/ProductCategoryController.cs index b5c5407..e7d8aaf 100644 --- a/NetinaShop.Api/Controller/ProductCategoryController.cs +++ b/NetinaShop.Api/Controller/ProductCategoryController.cs @@ -17,15 +17,15 @@ public class ProductCategoryController : ICarterModule .HasApiVersion(1.0); group.MapPost("", Post) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission,ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); group.MapPut("", Put) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/ProductController.cs b/NetinaShop.Api/Controller/ProductController.cs index e0296d9..5b49c73 100644 --- a/NetinaShop.Api/Controller/ProductController.cs +++ b/NetinaShop.Api/Controller/ProductController.cs @@ -19,19 +19,19 @@ public class ProductController : ICarterModule .HasApiVersion(1.0); group.MapPost("", Post) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); group.MapPut("", Put) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); group.MapPut("{productId}", ChangeDisplayedAsync) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageProducts)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/ProductReviewController.cs b/NetinaShop.Api/Controller/ProductReviewController.cs index 62f33d1..c945606 100644 --- a/NetinaShop.Api/Controller/ProductReviewController.cs +++ b/NetinaShop.Api/Controller/ProductReviewController.cs @@ -5,27 +5,31 @@ public class ProductReviewController : ICarterModule public void AddRoutes(IEndpointRouteBuilder app) { var group = app.NewVersionedApi("ProductReview") - .MapGroup("product/review") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .MapGroup("product/review"); group.MapGet("{id}", GetAsync) .WithDisplayName("GetOneAsync") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllReviews,ApplicationPermission.ManageReview)) .HasApiVersion(1.0); group.MapGet("", GetAllAsync) .WithDisplayName("GetAllAsync") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllReviews, ApplicationPermission.ManageReview)) .HasApiVersion(1.0); group.MapPost("", PostAsync) .WithDisplayName("PostReview") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageReview, ApplicationPermission.AddReview)) .HasApiVersion(1.0); group.MapPut("confirm/{id}", ConfirmAsync) .WithDisplayName("ConfirmAsync") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ConfirmReview, ApplicationPermission.ManageReview)) .HasApiVersion(1.0); group.MapDelete("{id}", DeleteAsync) .WithDisplayName("DeleteAsync") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageReview)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/RoleController.cs b/NetinaShop.Api/Controller/RoleController.cs index 2e81091..f3f7c05 100644 --- a/NetinaShop.Api/Controller/RoleController.cs +++ b/NetinaShop.Api/Controller/RoleController.cs @@ -8,28 +8,33 @@ public class RoleController : ICarterModule { var group = app.NewVersionedApi("Roles") - .MapGroup($"api/user/role") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .MapGroup($"api/user/role"); group.MapGet("", GetAllAsync) .WithDisplayName("GetAllRoles") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewRoles, ApplicationPermission.ManageRoles)) .HasApiVersion(1.0); group.MapGet("permission", GetAllPermissions) .WithDisplayName("GetAllPermissions") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewRoles, ApplicationPermission.ManageRoles)) .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) .WithDisplayName("GetRole") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewRoles, ApplicationPermission.ManageRoles)) .HasApiVersion(1.0); group.MapPost("", Post) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles)) .HasApiVersion(1.0); group.MapPut("", Put) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageRoles)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/ScraperController.cs b/NetinaShop.Api/Controller/ScraperController.cs index 75bca4b..0bcc7ef 100644 --- a/NetinaShop.Api/Controller/ScraperController.cs +++ b/NetinaShop.Api/Controller/ScraperController.cs @@ -6,7 +6,7 @@ public class ScraperController : ICarterModule { var group = app.NewVersionedApi("Scraper") .MapGroup("api/scraper") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission,ApplicationPermission.ManageScraper)); group.MapGet("digi", GetDigiProductsAsync) .WithDisplayName("GetDigiProducts") diff --git a/NetinaShop.Api/Controller/SettingController.cs b/NetinaShop.Api/Controller/SettingController.cs index 507d825..5c74c74 100644 --- a/NetinaShop.Api/Controller/SettingController.cs +++ b/NetinaShop.Api/Controller/SettingController.cs @@ -11,12 +11,12 @@ public class SettingController : ICarterModule group.MapGet("{settingName}", GetSettingAsync) .WithDisplayName("GetSetting") - .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewSettings,ApplicationPermission.ManageSettings)) .HasApiVersion(1.0); group.MapPost("{settingName}", PostSettingAsync) .WithDisplayName("PostSettingAsync") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageSettings)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/ShippingController.cs b/NetinaShop.Api/Controller/ShippingController.cs index 65e792f..efb315e 100644 --- a/NetinaShop.Api/Controller/ShippingController.cs +++ b/NetinaShop.Api/Controller/ShippingController.cs @@ -14,19 +14,19 @@ public class ShippingController : ICarterModule group.MapGet("{id}", GetAsync) .WithDisplayName("GetShipping") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewShipping, ApplicationPermission.ManageShipping)) .HasApiVersion(1.0); group.MapPost("", Post) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShipping)) .HasApiVersion(1.0); group.MapPut("", Put) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShipping)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShipping)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/UserAddressController.cs b/NetinaShop.Api/Controller/UserAddressController.cs index c86cca1..a6bc1f8 100644 --- a/NetinaShop.Api/Controller/UserAddressController.cs +++ b/NetinaShop.Api/Controller/UserAddressController.cs @@ -5,19 +5,21 @@ public class UserAddressController : ICarterModule public void AddRoutes(IEndpointRouteBuilder app) { var group = app.NewVersionedApi("UserAddress") - .MapGroup("api/user/address") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .MapGroup("api/user/address"); group.MapGet("", GetAddressesAsync) .WithDisplayName("Get Addresses") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); group.MapPost("", PostAddressesAsync) .WithDisplayName("Post Addresses") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); group.MapDelete("{id}", DeleteAddressesAsync) .WithDisplayName("Delete Address") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/Controller/UserController.cs b/NetinaShop.Api/Controller/UserController.cs index b08a2df..ec88027 100644 --- a/NetinaShop.Api/Controller/UserController.cs +++ b/NetinaShop.Api/Controller/UserController.cs @@ -12,40 +12,48 @@ public class UserController : ICarterModule { var group = app.NewVersionedApi("Users") - .MapGroup($"api/user") - .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + .MapGroup($"api/user"); group.MapGet("info", GetUserInfoAsync) .WithDisplayName("GetUserInfo") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); group.MapGet("", GetAllAsync) .WithDisplayName("GetAllUsers") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers)) .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) .WithDisplayName("GetUser") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers)) .HasApiVersion(1.0); group.MapGet("/order", GetUserOrdersAsync) .WithDisplayName("GetUserOrders") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewMineOrders)) .HasApiVersion(1.0); group.MapGet("{id}/order", GetUserOrdersByIdAsync) .WithDisplayName("GetUserOrders") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllOrders)) .HasApiVersion(1.0); group.MapGet("/changelog", GetChangeLogAsync) .WithDisplayName("GetChangeLog") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageDashboard)) .HasApiVersion(1.0); group.MapPost("", Post) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageUsers)) .HasApiVersion(1.0); group.MapPut("", Put) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageUsers)) .HasApiVersion(1.0); group.MapDelete("{id}", Delete) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageUsers)) .HasApiVersion(1.0); } diff --git a/NetinaShop.Api/NetinaShop.Api.csproj b/NetinaShop.Api/NetinaShop.Api.csproj index c872259..fbd78e8 100644 --- a/NetinaShop.Api/NetinaShop.Api.csproj +++ b/NetinaShop.Api/NetinaShop.Api.csproj @@ -88,6 +88,7 @@ + diff --git a/NetinaShop.Core/CoreServices/AccountService.cs b/NetinaShop.Core/CoreServices/AccountService.cs index 15db205..5b6758a 100644 --- a/NetinaShop.Core/CoreServices/AccountService.cs +++ b/NetinaShop.Core/CoreServices/AccountService.cs @@ -10,7 +10,7 @@ public class AccountService : IAccountService private readonly ICurrentUserService _currentUserService; private readonly IRepositoryWrapper _repositoryWrapper; private readonly ISmsService _smsService; - private readonly IManagerUserService _managerUserService; + private readonly IUserService _managerUserService; public AccountService( UserManager userManager, @@ -19,7 +19,7 @@ public class AccountService : IAccountService ICurrentUserService currentUserService, IRepositoryWrapper repositoryWrapper, ISmsService smsService, - IManagerUserService managerUserService) + IUserService managerUserService) { _userManager = userManager; _userSignInManager = userSignInManager; @@ -69,7 +69,7 @@ public class AccountService : IAccountService throw new AppException("شماره تلفن ارسالی اشتباه است"); var user = await _userManager.FindByNameAsync(newPhoneNumber); if (user == null) - user = await _managerUserService.CreateManagerAsync(phoneNumber); + user = await _managerUserService.CreateUserAsync(phoneNumber); var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone"); await _smsService.SendVerifyCodeAsync(newPhoneNumber, token); @@ -138,6 +138,14 @@ public class AccountService : IAccountService var roleResult = await _userManager.AddToRoleAsync(user, "Customer"); if (!roleResult.Succeeded) throw new AppException(string.Join('|', roleResult.Errors.Select(e => e.Description))); + + _repositoryWrapper.SetRepository() + .Add(new Customer + { + UserId = user.Id, + }); + await _repositoryWrapper.SaveChangesAsync(default); + return await CompleteLogin(user, cancellationToken); } diff --git a/NetinaShop.Core/EntityServices/DiscountHandlers/CalculateOrderDiscountCommandHandler.cs b/NetinaShop.Core/EntityServices/DiscountHandlers/CalculateOrderDiscountCommandHandler.cs index b0607ea..9d58685 100644 --- a/NetinaShop.Core/EntityServices/DiscountHandlers/CalculateOrderDiscountCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/DiscountHandlers/CalculateOrderDiscountCommandHandler.cs @@ -26,7 +26,7 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler() .TableNoTracking - .FirstOrDefaultAsync(f => f.UserId == userId && f.DiscountCode == discount.Code, cancellationToken); + .FirstOrDefaultAsync(f => f.CustomerId == userId && f.DiscountCode == discount.Code, cancellationToken); if (discountedUserOrder != null) throw new AppException("شما یک بار از این کد تخفیف استفاده کرده اید", ApiResultStatusCode.BadRequest); } @@ -37,7 +37,7 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler() .TableNoTracking - .CountAsync(f => f.UserId == firstPurchaseUserId && f.DiscountCode == discount.Code, cancellationToken); + .CountAsync(f => f.CustomerId == firstPurchaseUserId && f.DiscountCode == discount.Code, cancellationToken); if (userOrderCount > 0) throw new AppException("شما قبلا خریدی داشته اید و نمیتوانید از تخفیف اولین خرید استفاده کنید", ApiResultStatusCode.BadRequest); } diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs index 3daa6d4..2ec4f63 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs @@ -16,9 +16,9 @@ public class AddToOrderBagCommandHandler : IRequestHandler Handle(AddToOrderBagCommand request, CancellationToken cancellationToken) { if (_currentUserService.UserId == null) - throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id notfound", ApiResultStatusCode.BadRequest); if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) - throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id wrong", ApiResultStatusCode.BadRequest); var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken); diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/GetUserOrderBagQueryHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/GetUserOrderBagQueryHandler.cs index d9ad616..a02ee6b 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/GetUserOrderBagQueryHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/GetUserOrderBagQueryHandler.cs @@ -15,13 +15,27 @@ public class GetUserOrderBagQueryHandler : IRequestHandler Handle(GetUserOrderBagQuery request, CancellationToken cancellationToken) { if (_currentUserService.UserId == null) - throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id notfound", ApiResultStatusCode.BadRequest); if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) - throw new AppException("User id wrong",ApiResultStatusCode.BadRequest); + throw new AppException("Customer id wrong",ApiResultStatusCode.BadRequest); + + var customer = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(c => c.UserId == userId, cancellationToken); + if (customer == null) + { + customer = new Customer + { + UserId = userId + }; + _repositoryWrapper.SetRepository() + .Add(customer); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } var order = await _repositoryWrapper.SetRepository() .TableNoTracking - .FirstOrDefaultAsync(o => o.UserId == userId && o.OrderStatus == OrderStatus.OrderBag,cancellationToken); + .FirstOrDefaultAsync(o => o.CustomerId == customer.Id && o.OrderStatus == OrderStatus.OrderBag,cancellationToken); if (order == null) order = await _mediator.Send(new CreateBaseOrderCommand(userId),cancellationToken); diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs index 568719d..3a5fa65 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs @@ -15,9 +15,9 @@ public class RemoveFromOrderBagCommandHandler : IRequestHandler Handle(RemoveFromOrderBagCommand request, CancellationToken cancellationToken) { if (_currentUserService.UserId == null) - throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id notfound", ApiResultStatusCode.BadRequest); if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) - throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id wrong", ApiResultStatusCode.BadRequest); var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken); diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderBagCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderBagCommandHandler.cs index 56a8e87..ff2c7c8 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderBagCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderBagCommandHandler.cs @@ -16,9 +16,9 @@ public class SubmitOrderBagCommandHandler : IRequestHandler Handle(SubmitOrderBagCommand request, CancellationToken cancellationToken) { if (_currentUserService.UserId == null) - throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id notfound", ApiResultStatusCode.BadRequest); if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) - throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + throw new AppException("Customer id wrong", ApiResultStatusCode.BadRequest); var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken); diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs index 1bc97a6..bd23ec8 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs @@ -45,7 +45,7 @@ public class SubmitOrderPaymentCommandHandler : IRequestHandleru.UserName!= "09214802813") + .Where(u => u.UserName != "09214802813") .Skip(page * 15).Take(15) .Select(ApplicationUserMapper.ProjectToSDto) .ToListAsync(cancellationToken); else users = await _userManager.Users - .Where(a => a.PhoneNumber == phoneNumber && a.UserName!= "09214802813") + .Where(a => a.PhoneNumber == phoneNumber && a.UserName != "09214802813") .Skip(page * 15).Take(15) .Select(ApplicationUserMapper.ProjectToSDto) .ToListAsync(cancellationToken); @@ -79,7 +79,7 @@ public class UserService : IUserService } } - var returnUser = users.Where(r=> r.RoleName.Trim() != "مشتری" && r.FullName.Trim() != "همه کاره سیستم").ToList(); + var returnUser = users.Where(r => r.FullName.Trim() != "همه کاره سیستم").ToList(); return returnUser; } @@ -154,6 +154,26 @@ public class UserService : IUserService await _userManager.AddToRoleAsync(user, role.Name); } } + + var customer = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(c => c.UserId == user.Id, cancellationToken); + if (customer != null) + { + _repositoryWrapper.SetRepository() + .Add(new Customer + { + UserId = user.Id + }); + await _repositoryWrapper.SaveChangesAsync(default); + } + + _repositoryWrapper.SetRepository() + .Add(new Manager + { + UserId = user.Id + }); + await _repositoryWrapper.SaveChangesAsync(default); } return user; } @@ -250,6 +270,28 @@ public class UserService : IUserService var removeResult = await _userManager.DeleteAsync(user); if (!removeResult.Succeeded) throw new AppException(string.Join('|', removeResult.Errors.Select(e => e.Description))); + + var customer = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(c => c.UserId == userId, cancellationToken); + if (customer != null) + { + + _repositoryWrapper.SetRepository() + .Delete(customer); + await _repositoryWrapper.SaveChangesAsync(default); + } + var manager = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(c => c.UserId == userId, cancellationToken); + if (manager != null) + { + + _repositoryWrapper.SetRepository() + .Delete(manager); + await _repositoryWrapper.SaveChangesAsync(default); + } + return true; } @@ -284,7 +326,7 @@ public class UserService : IUserService public async Task> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default) { var roles = await _roleManager.Roles - .Where(r=>r.Name != "RootAdmin") + .Where(r => r.Name != "RootAdmin") .Skip(page * 15) .Take(15) .ToListAsync(cancellationToken); @@ -294,7 +336,7 @@ public class UserService : IUserService public async Task> GetRolesAsync(int? page, string? roleName, CancellationToken cancellationToken = default) { IQueryable roles; - if (roleName!=null) + if (roleName != null) roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.Name != "Customer" && r.PersianName.Trim().ToLower().Contains(roleName)); else roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.Name != "Customer"); @@ -360,7 +402,7 @@ public class UserService : IUserService var roleClaims = (await _roleManager.GetClaimsAsync(applicationRole)).Where(c => c.Type == CustomClaimType.Permission).ToList(); foreach (var roleClaim in roleClaims.ToList()) { - var removeResult = await _roleManager.RemoveClaimAsync(applicationRole,roleClaim); + var removeResult = await _roleManager.RemoveClaimAsync(applicationRole, roleClaim); if (!removeResult.Succeeded) throw new AppException(string.Join(" | ", removeResult.Errors.Select(e => e.Description))); } diff --git a/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs index 8666859..61a1609 100644 --- a/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs +++ b/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs @@ -2,6 +2,6 @@ public sealed record GetOrderLDtoQuery(Guid Id) : IRequest; -public sealed record GetUserOrdersQuery(Guid UserId = default) : IRequest>; +public sealed record GetUserOrdersQuery(Guid CustomerId = default) : IRequest>; public sealed record GetOrderQuery(Guid Id) : IRequest; public sealed record GetOrdersQuery(OrderQueryDateFilter? DateFilter, OrderStatus? OrderStatus,long? SelectedDate, int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs index 8f53f8a..616a90a 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs @@ -18,7 +18,7 @@ public class OrderSDto : BaseDto public DateTime OrderAt { get; set; } public int PreparingMinute { get; set; } public string DiscountCode { get; set; } = string.Empty; - public string UserFullName { get; set; } = string.Empty; - public string UserPhoneNumber { get; set; } = string.Empty; - public Guid UserId { get; set; } + public string CustomerFullName { get; set; } = string.Empty; + public string CustomerPhoneNumber { get; set; } = string.Empty; + public Guid CustomerId { get; set; } } diff --git a/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs index d8b8522..75b4b0e 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs @@ -14,7 +14,7 @@ public class PaymentSDto : BaseDto public PaymentStatus Status { get; set; } public Guid OrderId { get; set; } - public Guid UserId { get; set; } - public string UserFullName { get; set; } = string.Empty; - public string UserPhoneNumber { get; set; } = string.Empty; + public Guid CustomerId { get; set; } + public string CustomerFullName { get; set; } = string.Empty; + public string CustomerPhoneNumber { get; set; } = string.Empty; } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Accounting/Payment.cs b/NetinaShop.Domain/Entities/Accounting/Payment.cs index 4eb733d..8f13fd0 100644 --- a/NetinaShop.Domain/Entities/Accounting/Payment.cs +++ b/NetinaShop.Domain/Entities/Accounting/Payment.cs @@ -11,7 +11,7 @@ public partial class Payment : ApiEntity { } - public Payment(string factorNumber, double amount, string description, string transactionCode, string cardPan, string authority, PaymentType type, PaymentStatus status, Guid orderId, Guid userId) + public Payment(string factorNumber, double amount, string description, string transactionCode, string cardPan, string authority, PaymentType type, PaymentStatus status, Guid orderId, Guid customerId) { FactorNumber = factorNumber; Amount = amount; @@ -22,7 +22,7 @@ public partial class Payment : ApiEntity Type = type; Status = status; OrderId = orderId; - UserId = userId; + CustomerId = customerId; } public string FactorNumber { get; internal set; } = string.Empty; @@ -36,6 +36,6 @@ public partial class Payment : ApiEntity public Guid OrderId { get; internal set; } public Order? Order { get; internal set; } - public Guid UserId { get; internal set; } - public ApplicationUser? User { get; internal set; } + public Guid CustomerId { get; internal set; } + public Customer? Customer { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/Order.cs b/NetinaShop.Domain/Entities/Orders/Order.cs index f00e1ad..a8f0658 100644 --- a/NetinaShop.Domain/Entities/Orders/Order.cs +++ b/NetinaShop.Domain/Entities/Orders/Order.cs @@ -28,7 +28,7 @@ public partial class Order : ApiEntity DateTime orderAt, int preparingMinute, string discountCode, - Guid userId, + Guid customerId, OrderPaymentMethod paymentMethod) { FactorCode = factorCode; @@ -45,7 +45,7 @@ public partial class Order : ApiEntity OrderAt = orderAt; PreparingMinute = preparingMinute; DiscountCode = discountCode; - UserId = userId; + CustomerId = customerId; PaymentMethod = paymentMethod; } @@ -70,8 +70,8 @@ public partial class Order : ApiEntity public int PreparingMinute { get; internal set; } public string DiscountCode { get; internal set; } = string.Empty; - public Guid UserId { get; internal set; } - public Customer? User { get; internal set; } + public Guid CustomerId { get; internal set; } + public Customer? Customer { get; internal set; } public OrderDelivery? OrderDelivery { get; set; } diff --git a/NetinaShop.Domain/Mappers/CustomerMapper.g.cs b/NetinaShop.Domain/Mappers/CustomerMapper.g.cs index 5ee9051..1d162c8 100644 --- a/NetinaShop.Domain/Mappers/CustomerMapper.g.cs +++ b/NetinaShop.Domain/Mappers/CustomerMapper.g.cs @@ -1,6 +1,83 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Users; +using NetinaShop.Domain.Enums; + namespace NetinaShop.Domain.Mappers { public static partial class CustomerMapper { + public static Customer AdaptToCustomer(this CustomerSDto p1) + { + return p1 == null ? null : new Customer() + { + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static Customer AdaptTo(this CustomerSDto p2, Customer p3) + { + if (p2 == null) + { + return null; + } + Customer result = p3 ?? new Customer(); + + result.Id = p2.Id; + result.CreatedAt = p2.CreatedAt; + return result; + + } + public static CustomerSDto AdaptToSDto(this Customer p4) + { + return p4 == null ? null : new CustomerSDto() + { + PhoneNumber = p4.User != null ? p4.User.PhoneNumber : string.Empty, + FirstName = p4.User != null ? p4.User.FirstName : string.Empty, + LastName = p4.User != null ? p4.User.LastName : string.Empty, + BirthDate = p4.User != null ? p4.User.BirthDate : DateTime.MinValue, + Gender = p4.User != null ? p4.User.Gender : Gender.Male, + SignUpStatus = p4.User != null ? p4.User.SignUpStatus : SignUpStatus.StartSignOn, + NationalId = p4.User != null ? p4.User.NationalId : string.Empty, + Email = p4.User != null ? p4.User.Email : string.Empty, + Id = p4.Id, + CreatedAt = p4.CreatedAt + }; + } + public static CustomerSDto AdaptTo(this Customer p5, CustomerSDto p6) + { + if (p5 == null) + { + return null; + } + CustomerSDto result = p6 ?? new CustomerSDto(); + + result.PhoneNumber = p5.User != null ? p5.User.PhoneNumber : string.Empty; + result.FirstName = p5.User != null ? p5.User.FirstName : string.Empty; + result.LastName = p5.User != null ? p5.User.LastName : string.Empty; + result.BirthDate = p5.User != null ? p5.User.BirthDate : DateTime.MinValue; + result.Gender = p5.User != null ? p5.User.Gender : Gender.Male; + result.SignUpStatus = p5.User != null ? p5.User.SignUpStatus : SignUpStatus.StartSignOn; + result.NationalId = p5.User != null ? p5.User.NationalId : string.Empty; + result.Email = p5.User != null ? p5.User.Email : string.Empty; + result.Id = p5.Id; + result.CreatedAt = p5.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p7 => new CustomerSDto() + { + PhoneNumber = p7.User != null ? p7.User.PhoneNumber : string.Empty, + FirstName = p7.User != null ? p7.User.FirstName : string.Empty, + LastName = p7.User != null ? p7.User.LastName : string.Empty, + BirthDate = p7.User != null ? p7.User.BirthDate : DateTime.MinValue, + Gender = p7.User != null ? p7.User.Gender : Gender.Male, + SignUpStatus = p7.User != null ? p7.User.SignUpStatus : SignUpStatus.StartSignOn, + NationalId = p7.User != null ? p7.User.NationalId : string.Empty, + Email = p7.User != null ? p7.User.Email : string.Empty, + Id = p7.Id, + CreatedAt = p7.CreatedAt + }; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ManagerMapper.g.cs b/NetinaShop.Domain/Mappers/ManagerMapper.g.cs index 3f9e906..c2869bc 100644 --- a/NetinaShop.Domain/Mappers/ManagerMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ManagerMapper.g.cs @@ -2,6 +2,7 @@ using System; using System.Linq.Expressions; using NetinaShop.Domain.Dtos.SmallDtos; using NetinaShop.Domain.Entities.Users; +using NetinaShop.Domain.Enums; namespace NetinaShop.Domain.Mappers { @@ -12,15 +13,8 @@ namespace NetinaShop.Domain.Mappers return p1 == null ? null : new Manager() { LatestVersionUsed = p1.LatestVersionUsed, - FirstName = p1.FirstName, - LastName = p1.LastName, - NationalId = p1.NationalId, - BirthDate = p1.BirthDate, - Gender = p1.Gender, - SignUpStatus = p1.SignUpStatus, Id = p1.Id, - Email = p1.Email, - PhoneNumber = p1.PhoneNumber + CreatedAt = p1.CreatedAt }; } public static Manager AdaptTo(this ManagerSDto p2, Manager p3) @@ -32,15 +26,8 @@ namespace NetinaShop.Domain.Mappers Manager result = p3 ?? new Manager(); result.LatestVersionUsed = p2.LatestVersionUsed; - result.FirstName = p2.FirstName; - result.LastName = p2.LastName; - result.NationalId = p2.NationalId; - result.BirthDate = p2.BirthDate; - result.Gender = p2.Gender; - result.SignUpStatus = p2.SignUpStatus; result.Id = p2.Id; - result.Email = p2.Email; - result.PhoneNumber = p2.PhoneNumber; + result.CreatedAt = p2.CreatedAt; return result; } @@ -48,16 +35,17 @@ namespace NetinaShop.Domain.Mappers { return p4 == null ? null : new ManagerSDto() { - PhoneNumber = p4.PhoneNumber, - FirstName = p4.FirstName, - LastName = p4.LastName, - BirthDate = p4.BirthDate, - Gender = p4.Gender, - SignUpStatus = p4.SignUpStatus, - NationalId = p4.NationalId, - Email = p4.Email, + PhoneNumber = p4.User != null ? p4.User.PhoneNumber : string.Empty, + FirstName = p4.User != null ? p4.User.FirstName : string.Empty, + LastName = p4.User != null ? p4.User.LastName : string.Empty, + BirthDate = p4.User != null ? p4.User.BirthDate : DateTime.MinValue, + Gender = p4.User != null ? p4.User.Gender : Gender.Male, + SignUpStatus = p4.User != null ? p4.User.SignUpStatus : SignUpStatus.StartSignOn, + NationalId = p4.User != null ? p4.User.NationalId : string.Empty, + Email = p4.User != null ? p4.User.Email : string.Empty, LatestVersionUsed = p4.LatestVersionUsed, - Id = p4.Id + Id = p4.Id, + CreatedAt = p4.CreatedAt }; } public static ManagerSDto AdaptTo(this Manager p5, ManagerSDto p6) @@ -68,31 +56,33 @@ namespace NetinaShop.Domain.Mappers } ManagerSDto result = p6 ?? new ManagerSDto(); - result.PhoneNumber = p5.PhoneNumber; - result.FirstName = p5.FirstName; - result.LastName = p5.LastName; - result.BirthDate = p5.BirthDate; - result.Gender = p5.Gender; - result.SignUpStatus = p5.SignUpStatus; - result.NationalId = p5.NationalId; - result.Email = p5.Email; + result.PhoneNumber = p5.User != null ? p5.User.PhoneNumber : string.Empty; + result.FirstName = p5.User != null ? p5.User.FirstName : string.Empty; + result.LastName = p5.User != null ? p5.User.LastName : string.Empty; + result.BirthDate = p5.User != null ? p5.User.BirthDate : DateTime.MinValue; + result.Gender = p5.User != null ? p5.User.Gender : Gender.Male; + result.SignUpStatus = p5.User != null ? p5.User.SignUpStatus : SignUpStatus.StartSignOn; + result.NationalId = p5.User != null ? p5.User.NationalId : string.Empty; + result.Email = p5.User != null ? p5.User.Email : string.Empty; result.LatestVersionUsed = p5.LatestVersionUsed; result.Id = p5.Id; + result.CreatedAt = p5.CreatedAt; return result; } public static Expression> ProjectToSDto => p7 => new ManagerSDto() { - PhoneNumber = p7.PhoneNumber, - FirstName = p7.FirstName, - LastName = p7.LastName, - BirthDate = p7.BirthDate, - Gender = p7.Gender, - SignUpStatus = p7.SignUpStatus, - NationalId = p7.NationalId, - Email = p7.Email, + PhoneNumber = p7.User != null ? p7.User.PhoneNumber : string.Empty, + FirstName = p7.User != null ? p7.User.FirstName : string.Empty, + LastName = p7.User != null ? p7.User.LastName : string.Empty, + BirthDate = p7.User != null ? p7.User.BirthDate : DateTime.MinValue, + Gender = p7.User != null ? p7.User.Gender : Gender.Male, + SignUpStatus = p7.User != null ? p7.User.SignUpStatus : SignUpStatus.StartSignOn, + NationalId = p7.User != null ? p7.User.NationalId : string.Empty, + Email = p7.User != null ? p7.User.Email : string.Empty, LatestVersionUsed = p7.LatestVersionUsed, - Id = p7.Id + Id = p7.Id, + CreatedAt = p7.CreatedAt }; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/MarketerMapper.g.cs b/NetinaShop.Domain/Mappers/MarketerMapper.g.cs index a7fb682..55c836e 100644 --- a/NetinaShop.Domain/Mappers/MarketerMapper.g.cs +++ b/NetinaShop.Domain/Mappers/MarketerMapper.g.cs @@ -1,6 +1,93 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Users; +using NetinaShop.Domain.Enums; + namespace NetinaShop.Domain.Mappers { public static partial class MarketerMapper { + public static Marketer AdaptToMarketer(this MarketerSDto p1) + { + return p1 == null ? null : new Marketer() + { + FatherName = p1.FatherName, + Shaba = p1.Shaba, + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static Marketer AdaptTo(this MarketerSDto p2, Marketer p3) + { + if (p2 == null) + { + return null; + } + Marketer result = p3 ?? new Marketer(); + + result.FatherName = p2.FatherName; + result.Shaba = p2.Shaba; + result.Id = p2.Id; + result.CreatedAt = p2.CreatedAt; + return result; + + } + public static MarketerSDto AdaptToSDto(this Marketer p4) + { + return p4 == null ? null : new MarketerSDto() + { + PhoneNumber = p4.User != null ? p4.User.PhoneNumber : string.Empty, + FirstName = p4.User != null ? p4.User.FirstName : string.Empty, + LastName = p4.User != null ? p4.User.LastName : string.Empty, + BirthDate = p4.User != null ? p4.User.BirthDate : DateTime.MinValue, + Gender = p4.User != null ? p4.User.Gender : Gender.Male, + SignUpStatus = p4.User != null ? p4.User.SignUpStatus : SignUpStatus.StartSignOn, + NationalId = p4.User != null ? p4.User.NationalId : string.Empty, + Email = p4.User != null ? p4.User.Email : string.Empty, + FatherName = p4.FatherName, + Shaba = p4.Shaba, + Id = p4.Id, + CreatedAt = p4.CreatedAt + }; + } + public static MarketerSDto AdaptTo(this Marketer p5, MarketerSDto p6) + { + if (p5 == null) + { + return null; + } + MarketerSDto result = p6 ?? new MarketerSDto(); + + result.PhoneNumber = p5.User != null ? p5.User.PhoneNumber : string.Empty; + result.FirstName = p5.User != null ? p5.User.FirstName : string.Empty; + result.LastName = p5.User != null ? p5.User.LastName : string.Empty; + result.BirthDate = p5.User != null ? p5.User.BirthDate : DateTime.MinValue; + result.Gender = p5.User != null ? p5.User.Gender : Gender.Male; + result.SignUpStatus = p5.User != null ? p5.User.SignUpStatus : SignUpStatus.StartSignOn; + result.NationalId = p5.User != null ? p5.User.NationalId : string.Empty; + result.Email = p5.User != null ? p5.User.Email : string.Empty; + result.FatherName = p5.FatherName; + result.Shaba = p5.Shaba; + result.Id = p5.Id; + result.CreatedAt = p5.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p7 => new MarketerSDto() + { + PhoneNumber = p7.User != null ? p7.User.PhoneNumber : string.Empty, + FirstName = p7.User != null ? p7.User.FirstName : string.Empty, + LastName = p7.User != null ? p7.User.LastName : string.Empty, + BirthDate = p7.User != null ? p7.User.BirthDate : DateTime.MinValue, + Gender = p7.User != null ? p7.User.Gender : Gender.Male, + SignUpStatus = p7.User != null ? p7.User.SignUpStatus : SignUpStatus.StartSignOn, + NationalId = p7.User != null ? p7.User.NationalId : string.Empty, + Email = p7.User != null ? p7.User.Email : string.Empty, + FatherName = p7.FatherName, + Shaba = p7.Shaba, + Id = p7.Id, + CreatedAt = p7.CreatedAt + }; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/OrderMapper.g.cs b/NetinaShop.Domain/Mappers/OrderMapper.g.cs index 97a5ab6..36ef3e8 100644 --- a/NetinaShop.Domain/Mappers/OrderMapper.g.cs +++ b/NetinaShop.Domain/Mappers/OrderMapper.g.cs @@ -35,7 +35,6 @@ namespace NetinaShop.Domain.Mappers OrderAt = p1.OrderAt, PreparingMinute = p1.PreparingMinute, DiscountCode = p1.DiscountCode, - User = new ApplicationUser() {PhoneNumber = p1.UserPhoneNumber}, OrderDelivery = p1.OrderDelivery == null ? null : new OrderDelivery() { AddressId = p1.OrderDelivery.AddressId, @@ -79,398 +78,377 @@ namespace NetinaShop.Domain.Mappers result.OrderAt = p4.OrderAt; result.PreparingMinute = p4.PreparingMinute; result.DiscountCode = p4.DiscountCode; - result.User = funcMain3(new Never(), result.User, p4); - result.OrderDelivery = funcMain4(p4.OrderDelivery, result.OrderDelivery); - result.OrderProducts = funcMain7(p4.OrderProducts, result.OrderProducts); - result.Payments = funcMain8(p4.Payments, result.Payments); + result.OrderDelivery = funcMain3(p4.OrderDelivery, result.OrderDelivery); + result.OrderProducts = funcMain6(p4.OrderProducts, result.OrderProducts); + result.Payments = funcMain7(p4.Payments, result.Payments); result.Id = p4.Id; result.CreatedAt = p4.CreatedAt; return result; } - public static Expression> ProjectToOrder => p18 => new Order() + public static Expression> ProjectToOrder => p16 => new Order() { - FactorCode = p18.FactorCode, - TotalProductsPrice = (double)p18.TotalProductsPrice, - PackingPrice = (double)p18.PackingPrice, - ServicePrice = (double)p18.ServicePrice, - DeliveryPrice = (double)p18.DeliveryPrice, - DiscountPrice = (double)p18.DiscountPrice, - DiscountCodePrice = p18.DiscountCodePrice, - ProductDiscountPrice = p18.ProductDiscountPrice, - TaxesPrice = (double)p18.TaxesPrice, - TotalPrice = (double)p18.TotalPrice, - IsPayed = p18.IsPayed, - OrderStatus = p18.OrderStatus, - DoneAt = p18.DoneAt, - OrderAt = p18.OrderAt, - PreparingMinute = p18.PreparingMinute, - DiscountCode = p18.DiscountCode, - User = new ApplicationUser() {PhoneNumber = p18.UserPhoneNumber}, - OrderDelivery = p18.OrderDelivery == null ? null : new OrderDelivery() + FactorCode = p16.FactorCode, + TotalProductsPrice = (double)p16.TotalProductsPrice, + PackingPrice = (double)p16.PackingPrice, + ServicePrice = (double)p16.ServicePrice, + DeliveryPrice = (double)p16.DeliveryPrice, + DiscountPrice = (double)p16.DiscountPrice, + DiscountCodePrice = p16.DiscountCodePrice, + ProductDiscountPrice = p16.ProductDiscountPrice, + TaxesPrice = (double)p16.TaxesPrice, + TotalPrice = (double)p16.TotalPrice, + IsPayed = p16.IsPayed, + OrderStatus = p16.OrderStatus, + DoneAt = p16.DoneAt, + OrderAt = p16.OrderAt, + PreparingMinute = p16.PreparingMinute, + DiscountCode = p16.DiscountCode, + OrderDelivery = p16.OrderDelivery == null ? null : new OrderDelivery() { - AddressId = p18.OrderDelivery.AddressId, - Address = p18.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p18.OrderDelivery.Address, typeof(UserAddress)), - DeliveryCost = p18.OrderDelivery.DeliveryCost, - TrackingCode = p18.OrderDelivery.TrackingCode, - ShippingId = p18.OrderDelivery.ShippingId, - Shipping = new Shipping() {Id = p18.OrderDelivery.ShippingId}, - OrderId = p18.OrderDelivery.OrderId, - Order = new Order() {Id = p18.OrderDelivery.OrderId}, - Id = p18.OrderDelivery.Id, - CreatedAt = p18.OrderDelivery.CreatedAt + AddressId = p16.OrderDelivery.AddressId, + Address = p16.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p16.OrderDelivery.Address, typeof(UserAddress)), + DeliveryCost = p16.OrderDelivery.DeliveryCost, + TrackingCode = p16.OrderDelivery.TrackingCode, + ShippingId = p16.OrderDelivery.ShippingId, + Shipping = new Shipping() {Id = p16.OrderDelivery.ShippingId}, + OrderId = p16.OrderDelivery.OrderId, + Order = new Order() {Id = p16.OrderDelivery.OrderId}, + Id = p16.OrderDelivery.Id, + CreatedAt = p16.OrderDelivery.CreatedAt }, - OrderProducts = p18.OrderProducts.Select(p19 => new OrderProduct() + OrderProducts = p16.OrderProducts.Select(p17 => new OrderProduct() { - Count = p19.Count, - ProductFee = p19.ProductFee, - ProductFeeWithDiscount = p19.ProductFeeWithDiscount, - HasDiscount = p19.HasDiscount, - ProductCost = p19.ProductCost, - PackingFee = p19.PackingFee, - PackingCost = p19.PackingCost, - OrderProductStatus = p19.OrderProductStatus, - ProductId = p19.ProductId, + Count = p17.Count, + ProductFee = p17.ProductFee, + ProductFeeWithDiscount = p17.ProductFeeWithDiscount, + HasDiscount = p17.HasDiscount, + ProductCost = p17.ProductCost, + PackingFee = p17.PackingFee, + PackingCost = p17.PackingCost, + OrderProductStatus = p17.OrderProductStatus, + ProductId = p17.ProductId, Product = new Product() { - Cost = p19.ProductCost, - Id = p19.ProductId + Cost = p17.ProductCost, + Id = p17.ProductId + }, + OrderId = p17.OrderId, + Order = new Order() {Id = p17.OrderId}, + Id = p17.Id, + CreatedAt = p17.CreatedAt + }).ToList(), + Payments = p16.Payments.Select(p18 => new Payment() + { + FactorNumber = p18.FactorNumber, + Amount = p18.Amount, + Description = p18.Description, + TransactionCode = p18.TransactionCode, + CardPan = p18.CardPan, + Authority = p18.Authority, + Type = p18.Type, + Status = p18.Status, + OrderId = p18.OrderId, + Order = new Order() {Id = p18.OrderId}, + Id = p18.Id, + CreatedAt = p18.CreatedAt + }).ToList(), + Id = p16.Id, + CreatedAt = p16.CreatedAt + }; + public static OrderLDto AdaptToLDto(this Order p19) + { + return p19 == null ? null : new OrderLDto() + { + FactorCode = p19.FactorCode, + TotalPrice = (long)p19.TotalPrice, + DeliveryPrice = (long)p19.DeliveryPrice, + TaxesPrice = (long)p19.TaxesPrice, + ServicePrice = (long)p19.ServicePrice, + PackingPrice = (long)p19.PackingPrice, + TotalProductsPrice = (long)p19.TotalProductsPrice, + DiscountCodePrice = p19.DiscountCodePrice, + ProductDiscountPrice = p19.ProductDiscountPrice, + DiscountPrice = (long)p19.DiscountPrice, + IsPayed = p19.IsPayed, + OrderStatus = p19.OrderStatus, + DoneAt = p19.DoneAt, + OrderAt = p19.OrderAt, + PreparingMinute = p19.PreparingMinute, + DiscountCode = p19.DiscountCode, + OrderProducts = funcMain8(p19.OrderProducts), + Payments = funcMain9(p19.Payments), + OrderDelivery = p19.OrderDelivery == null ? null : new OrderDeliverySDto() + { + Province = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.Province : string.Empty, + City = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.City : string.Empty, + Plaque = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.Plaque : string.Empty, + LocationLat = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.LocationLat : 0f, + LocationLong = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.LocationLong : 0f, + Address = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.Address : string.Empty, + PostalCode = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.PostalCode : string.Empty, + TrackingCode = p19.OrderDelivery.TrackingCode, + ReceiverPhoneNumber = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.ReceiverPhoneNumber : string.Empty, + ReceiverFullName = p19.OrderDelivery.Address != null ? p19.OrderDelivery.Address.ReceiverFullName : string.Empty, + ShippingMethod = p19.OrderDelivery.Shipping != null ? p19.OrderDelivery.Shipping.Name : string.Empty, + DeliveryCost = p19.OrderDelivery.DeliveryCost, + AddressId = p19.OrderDelivery.AddressId, + OrderId = p19.OrderDelivery.OrderId, + ShippingId = p19.OrderDelivery.ShippingId, + Id = p19.OrderDelivery.Id, + CreatedAt = p19.OrderDelivery.CreatedAt }, - OrderId = p19.OrderId, - Order = new Order() {Id = p19.OrderId}, Id = p19.Id, CreatedAt = p19.CreatedAt - }).ToList(), - Payments = p18.Payments.Select(p20 => new Payment() - { - FactorNumber = p20.FactorNumber, - Amount = p20.Amount, - Description = p20.Description, - TransactionCode = p20.TransactionCode, - CardPan = p20.CardPan, - Authority = p20.Authority, - Type = p20.Type, - Status = p20.Status, - OrderId = p20.OrderId, - Order = new Order() {Id = p20.OrderId}, - UserId = p20.UserId, - User = new ApplicationUser() - { - Id = p20.UserId, - PhoneNumber = p20.UserPhoneNumber - }, - Id = p20.Id, - CreatedAt = p20.CreatedAt - }).ToList(), - Id = p18.Id, - CreatedAt = p18.CreatedAt - }; - public static OrderLDto AdaptToLDto(this Order p21) - { - return p21 == null ? null : new OrderLDto() - { - FactorCode = p21.FactorCode, - TotalPrice = (long)p21.TotalPrice, - DeliveryPrice = (long)p21.DeliveryPrice, - TaxesPrice = (long)p21.TaxesPrice, - ServicePrice = (long)p21.ServicePrice, - PackingPrice = (long)p21.PackingPrice, - TotalProductsPrice = (long)p21.TotalProductsPrice, - DiscountCodePrice = p21.DiscountCodePrice, - ProductDiscountPrice = p21.ProductDiscountPrice, - DiscountPrice = (long)p21.DiscountPrice, - IsPayed = p21.IsPayed, - OrderStatus = p21.OrderStatus, - DoneAt = p21.DoneAt, - OrderAt = p21.OrderAt, - PreparingMinute = p21.PreparingMinute, - DiscountCode = p21.DiscountCode, - UserFullName = p21.User != null ? p21.User.FirstName + " " + p21.User.LastName : string.Empty, - UserPhoneNumber = p21.User != null ? p21.User.PhoneNumber : string.Empty, - OrderProducts = funcMain9(p21.OrderProducts), - Payments = funcMain10(p21.Payments), - OrderDelivery = p21.OrderDelivery == null ? null : new OrderDeliverySDto() - { - Province = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.Province : string.Empty, - City = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.City : string.Empty, - Plaque = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.Plaque : string.Empty, - LocationLat = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.LocationLat : 0f, - LocationLong = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.LocationLong : 0f, - Address = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.Address : string.Empty, - PostalCode = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.PostalCode : string.Empty, - TrackingCode = p21.OrderDelivery.TrackingCode, - ReceiverPhoneNumber = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.ReceiverPhoneNumber : string.Empty, - ReceiverFullName = p21.OrderDelivery.Address != null ? p21.OrderDelivery.Address.ReceiverFullName : string.Empty, - ShippingMethod = p21.OrderDelivery.Shipping != null ? p21.OrderDelivery.Shipping.Name : string.Empty, - DeliveryCost = p21.OrderDelivery.DeliveryCost, - AddressId = p21.OrderDelivery.AddressId, - OrderId = p21.OrderDelivery.OrderId, - ShippingId = p21.OrderDelivery.ShippingId, - Id = p21.OrderDelivery.Id, - CreatedAt = p21.OrderDelivery.CreatedAt - }, - Id = p21.Id, - CreatedAt = p21.CreatedAt }; } - public static OrderLDto AdaptTo(this Order p24, OrderLDto p25) + public static OrderLDto AdaptTo(this Order p22, OrderLDto p23) { - if (p24 == null) + if (p22 == null) { return null; } - OrderLDto result = p25 ?? new OrderLDto(); + OrderLDto result = p23 ?? new OrderLDto(); - result.FactorCode = p24.FactorCode; - result.TotalPrice = (long)p24.TotalPrice; - result.DeliveryPrice = (long)p24.DeliveryPrice; - result.TaxesPrice = (long)p24.TaxesPrice; - result.ServicePrice = (long)p24.ServicePrice; - result.PackingPrice = (long)p24.PackingPrice; - result.TotalProductsPrice = (long)p24.TotalProductsPrice; - result.DiscountCodePrice = p24.DiscountCodePrice; - result.ProductDiscountPrice = p24.ProductDiscountPrice; - result.DiscountPrice = (long)p24.DiscountPrice; - result.IsPayed = p24.IsPayed; - result.OrderStatus = p24.OrderStatus; - result.DoneAt = p24.DoneAt; - result.OrderAt = p24.OrderAt; - result.PreparingMinute = p24.PreparingMinute; - result.DiscountCode = p24.DiscountCode; - result.UserFullName = p24.User != null ? p24.User.FirstName + " " + p24.User.LastName : string.Empty; - result.UserPhoneNumber = p24.User != null ? p24.User.PhoneNumber : string.Empty; - result.OrderProducts = funcMain11(p24.OrderProducts, result.OrderProducts); - result.Payments = funcMain12(p24.Payments, result.Payments); - result.OrderDelivery = funcMain13(p24.OrderDelivery, result.OrderDelivery); - result.Id = p24.Id; - result.CreatedAt = p24.CreatedAt; + result.FactorCode = p22.FactorCode; + result.TotalPrice = (long)p22.TotalPrice; + result.DeliveryPrice = (long)p22.DeliveryPrice; + result.TaxesPrice = (long)p22.TaxesPrice; + result.ServicePrice = (long)p22.ServicePrice; + result.PackingPrice = (long)p22.PackingPrice; + result.TotalProductsPrice = (long)p22.TotalProductsPrice; + result.DiscountCodePrice = p22.DiscountCodePrice; + result.ProductDiscountPrice = p22.ProductDiscountPrice; + result.DiscountPrice = (long)p22.DiscountPrice; + result.IsPayed = p22.IsPayed; + result.OrderStatus = p22.OrderStatus; + result.DoneAt = p22.DoneAt; + result.OrderAt = p22.OrderAt; + result.PreparingMinute = p22.PreparingMinute; + result.DiscountCode = p22.DiscountCode; + result.OrderProducts = funcMain10(p22.OrderProducts, result.OrderProducts); + result.Payments = funcMain11(p22.Payments, result.Payments); + result.OrderDelivery = funcMain12(p22.OrderDelivery, result.OrderDelivery); + result.Id = p22.Id; + result.CreatedAt = p22.CreatedAt; return result; } - public static Expression> ProjectToLDto => p32 => new OrderLDto() + public static Expression> ProjectToLDto => p30 => new OrderLDto() { - FactorCode = p32.FactorCode, - TotalPrice = (long)p32.TotalPrice, - DeliveryPrice = (long)p32.DeliveryPrice, - TaxesPrice = (long)p32.TaxesPrice, - ServicePrice = (long)p32.ServicePrice, - PackingPrice = (long)p32.PackingPrice, - TotalProductsPrice = (long)p32.TotalProductsPrice, - DiscountCodePrice = p32.DiscountCodePrice, - ProductDiscountPrice = p32.ProductDiscountPrice, - DiscountPrice = (long)p32.DiscountPrice, - IsPayed = p32.IsPayed, - OrderStatus = p32.OrderStatus, - DoneAt = p32.DoneAt, - OrderAt = p32.OrderAt, - PreparingMinute = p32.PreparingMinute, - DiscountCode = p32.DiscountCode, - UserFullName = p32.User != null ? p32.User.FirstName + " " + p32.User.LastName : string.Empty, - UserPhoneNumber = p32.User != null ? p32.User.PhoneNumber : string.Empty, - OrderProducts = p32.OrderProducts.Select(p33 => new OrderProductSDto() + FactorCode = p30.FactorCode, + TotalPrice = (long)p30.TotalPrice, + DeliveryPrice = (long)p30.DeliveryPrice, + TaxesPrice = (long)p30.TaxesPrice, + ServicePrice = (long)p30.ServicePrice, + PackingPrice = (long)p30.PackingPrice, + TotalProductsPrice = (long)p30.TotalProductsPrice, + DiscountCodePrice = p30.DiscountCodePrice, + ProductDiscountPrice = p30.ProductDiscountPrice, + DiscountPrice = (long)p30.DiscountPrice, + IsPayed = p30.IsPayed, + OrderStatus = p30.OrderStatus, + DoneAt = p30.DoneAt, + OrderAt = p30.OrderAt, + PreparingMinute = p30.PreparingMinute, + DiscountCode = p30.DiscountCode, + OrderProducts = p30.OrderProducts.Select(p31 => new OrderProductSDto() { - Count = p33.Count, - ProductFee = p33.ProductFee, - ProductFeeWithDiscount = p33.ProductFeeWithDiscount, - HasDiscount = p33.HasDiscount, - ProductCost = p33.ProductCost, - PackingFee = p33.PackingFee, - PackingCost = p33.PackingCost, - OrderProductStatus = p33.OrderProductStatus, - ProductId = p33.ProductId, - ProductName = p33.Product != null ? p33.Product.PersianName : string.Empty, - OrderId = p33.OrderId, + Count = p31.Count, + ProductFee = p31.ProductFee, + ProductFeeWithDiscount = p31.ProductFeeWithDiscount, + HasDiscount = p31.HasDiscount, + ProductCost = p31.ProductCost, + PackingFee = p31.PackingFee, + PackingCost = p31.PackingCost, + OrderProductStatus = p31.OrderProductStatus, + ProductId = p31.ProductId, + ProductName = p31.Product != null ? p31.Product.PersianName : string.Empty, + OrderId = p31.OrderId, + Id = p31.Id, + CreatedAt = p31.CreatedAt + }).ToList(), + Payments = p30.Payments.Select(p32 => new PaymentSDto() + { + FactorNumber = p32.FactorNumber, + Amount = p32.Amount, + Description = p32.Description, + TransactionCode = p32.TransactionCode, + CardPan = p32.CardPan, + Authority = p32.Authority, + Type = p32.Type, + Status = p32.Status, + OrderId = p32.OrderId, + Id = p32.Id, + CreatedAt = p32.CreatedAt + }).ToList(), + OrderDelivery = p30.OrderDelivery == null ? null : new OrderDeliverySDto() + { + Province = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.Province : string.Empty, + City = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.City : string.Empty, + Plaque = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.Plaque : string.Empty, + LocationLat = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.LocationLat : 0f, + LocationLong = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.LocationLong : 0f, + Address = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.Address : string.Empty, + PostalCode = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.PostalCode : string.Empty, + TrackingCode = p30.OrderDelivery.TrackingCode, + ReceiverPhoneNumber = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.ReceiverPhoneNumber : string.Empty, + ReceiverFullName = p30.OrderDelivery.Address != null ? p30.OrderDelivery.Address.ReceiverFullName : string.Empty, + ShippingMethod = p30.OrderDelivery.Shipping != null ? p30.OrderDelivery.Shipping.Name : string.Empty, + DeliveryCost = p30.OrderDelivery.DeliveryCost, + AddressId = p30.OrderDelivery.AddressId, + OrderId = p30.OrderDelivery.OrderId, + ShippingId = p30.OrderDelivery.ShippingId, + Id = p30.OrderDelivery.Id, + CreatedAt = p30.OrderDelivery.CreatedAt + }, + Id = p30.Id, + CreatedAt = p30.CreatedAt + }; + public static Order AdaptToOrder(this OrderSDto p33) + { + return p33 == null ? null : new Order() + { + FactorCode = p33.FactorCode, + TotalProductsPrice = p33.TotalProductsPrice, + PackingPrice = p33.PackingPrice, + ServicePrice = p33.ServicePrice, + DeliveryPrice = p33.DeliveryPrice, + DiscountPrice = p33.DiscountPrice, + DiscountCodePrice = p33.DiscountCodePrice, + ProductDiscountPrice = p33.ProductDiscountPrice, + TaxesPrice = p33.TaxesPrice, + TotalPrice = p33.TotalPrice, + IsPayed = p33.IsPayed, + OrderStatus = p33.OrderStatus, + DoneAt = p33.DoneAt, + OrderAt = p33.OrderAt, + PayedAt = p33.PayedAt, + PreparingMinute = p33.PreparingMinute, + DiscountCode = p33.DiscountCode, + CustomerId = p33.CustomerId, + Customer = new Customer() {Id = p33.CustomerId}, Id = p33.Id, CreatedAt = p33.CreatedAt - }).ToList(), - Payments = p32.Payments.Select(p34 => new PaymentSDto() - { - FactorNumber = p34.FactorNumber, - Amount = p34.Amount, - Description = p34.Description, - TransactionCode = p34.TransactionCode, - CardPan = p34.CardPan, - Authority = p34.Authority, - Type = p34.Type, - Status = p34.Status, - OrderId = p34.OrderId, - UserId = p34.UserId, - UserFullName = p34.User != null ? p34.User.FirstName + " " + p34.User.LastName : string.Empty, - UserPhoneNumber = p34.User != null ? p34.User.PhoneNumber : string.Empty, - Id = p34.Id, - CreatedAt = p34.CreatedAt - }).ToList(), - OrderDelivery = p32.OrderDelivery == null ? null : new OrderDeliverySDto() - { - Province = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.Province : string.Empty, - City = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.City : string.Empty, - Plaque = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.Plaque : string.Empty, - LocationLat = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.LocationLat : 0f, - LocationLong = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.LocationLong : 0f, - Address = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.Address : string.Empty, - PostalCode = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.PostalCode : string.Empty, - TrackingCode = p32.OrderDelivery.TrackingCode, - ReceiverPhoneNumber = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.ReceiverPhoneNumber : string.Empty, - ReceiverFullName = p32.OrderDelivery.Address != null ? p32.OrderDelivery.Address.ReceiverFullName : string.Empty, - ShippingMethod = p32.OrderDelivery.Shipping != null ? p32.OrderDelivery.Shipping.Name : string.Empty, - DeliveryCost = p32.OrderDelivery.DeliveryCost, - AddressId = p32.OrderDelivery.AddressId, - OrderId = p32.OrderDelivery.OrderId, - ShippingId = p32.OrderDelivery.ShippingId, - Id = p32.OrderDelivery.Id, - CreatedAt = p32.OrderDelivery.CreatedAt - }, - Id = p32.Id, - CreatedAt = p32.CreatedAt - }; - public static Order AdaptToOrder(this OrderSDto p35) - { - return p35 == null ? null : new Order() - { - FactorCode = p35.FactorCode, - TotalProductsPrice = p35.TotalProductsPrice, - PackingPrice = p35.PackingPrice, - ServicePrice = p35.ServicePrice, - DeliveryPrice = p35.DeliveryPrice, - DiscountPrice = p35.DiscountPrice, - DiscountCodePrice = p35.DiscountCodePrice, - ProductDiscountPrice = p35.ProductDiscountPrice, - TaxesPrice = p35.TaxesPrice, - TotalPrice = p35.TotalPrice, - IsPayed = p35.IsPayed, - OrderStatus = p35.OrderStatus, - DoneAt = p35.DoneAt, - OrderAt = p35.OrderAt, - PayedAt = p35.PayedAt, - PreparingMinute = p35.PreparingMinute, - DiscountCode = p35.DiscountCode, - UserId = p35.UserId, - User = new ApplicationUser() - { - Id = p35.UserId, - PhoneNumber = p35.UserPhoneNumber - }, - Id = p35.Id, - CreatedAt = p35.CreatedAt }; } - public static Order AdaptTo(this OrderSDto p36, Order p37) + public static Order AdaptTo(this OrderSDto p34, Order p35) { - if (p36 == null) + if (p34 == null) { return null; } - Order result = p37 ?? new Order(); + Order result = p35 ?? new Order(); - result.FactorCode = p36.FactorCode; - result.TotalProductsPrice = p36.TotalProductsPrice; - result.PackingPrice = p36.PackingPrice; - result.ServicePrice = p36.ServicePrice; - result.DeliveryPrice = p36.DeliveryPrice; - result.DiscountPrice = p36.DiscountPrice; - result.DiscountCodePrice = p36.DiscountCodePrice; - result.ProductDiscountPrice = p36.ProductDiscountPrice; - result.TaxesPrice = p36.TaxesPrice; - result.TotalPrice = p36.TotalPrice; - result.IsPayed = p36.IsPayed; - result.OrderStatus = p36.OrderStatus; - result.DoneAt = p36.DoneAt; - result.OrderAt = p36.OrderAt; - result.PayedAt = p36.PayedAt; - result.PreparingMinute = p36.PreparingMinute; - result.DiscountCode = p36.DiscountCode; - result.UserId = p36.UserId; - result.User = funcMain14(new Never(), result.User, p36); - result.Id = p36.Id; - result.CreatedAt = p36.CreatedAt; + result.FactorCode = p34.FactorCode; + result.TotalProductsPrice = p34.TotalProductsPrice; + result.PackingPrice = p34.PackingPrice; + result.ServicePrice = p34.ServicePrice; + result.DeliveryPrice = p34.DeliveryPrice; + result.DiscountPrice = p34.DiscountPrice; + result.DiscountCodePrice = p34.DiscountCodePrice; + result.ProductDiscountPrice = p34.ProductDiscountPrice; + result.TaxesPrice = p34.TaxesPrice; + result.TotalPrice = p34.TotalPrice; + result.IsPayed = p34.IsPayed; + result.OrderStatus = p34.OrderStatus; + result.DoneAt = p34.DoneAt; + result.OrderAt = p34.OrderAt; + result.PayedAt = p34.PayedAt; + result.PreparingMinute = p34.PreparingMinute; + result.DiscountCode = p34.DiscountCode; + result.CustomerId = p34.CustomerId; + result.Customer = funcMain13(new Never(), result.Customer, p34); + result.Id = p34.Id; + result.CreatedAt = p34.CreatedAt; return result; } - public static OrderSDto AdaptToSDto(this Order p40) + public static OrderSDto AdaptToSDto(this Order p38) { - return p40 == null ? null : new OrderSDto() + return p38 == null ? null : new OrderSDto() { - TotalPrice = p40.TotalPrice, - FactorCode = p40.FactorCode, - DeliveryPrice = p40.DeliveryPrice, - TaxesPrice = p40.TaxesPrice, - ServicePrice = p40.ServicePrice, - PackingPrice = p40.PackingPrice, - TotalProductsPrice = p40.TotalProductsPrice, - DiscountPrice = p40.DiscountPrice, - DiscountCodePrice = p40.DiscountCodePrice, - ProductDiscountPrice = p40.ProductDiscountPrice, - IsPayed = p40.IsPayed, - OrderStatus = p40.OrderStatus, - PayedAt = p40.PayedAt, - DoneAt = p40.DoneAt, - OrderAt = p40.OrderAt, - PreparingMinute = p40.PreparingMinute, - DiscountCode = p40.DiscountCode, - UserFullName = p40.User != null ? p40.User.FirstName + " " + p40.User.LastName : string.Empty, - UserPhoneNumber = p40.User != null ? p40.User.PhoneNumber : string.Empty, - UserId = p40.UserId, - Id = p40.Id, - CreatedAt = p40.CreatedAt + TotalPrice = p38.TotalPrice, + FactorCode = p38.FactorCode, + DeliveryPrice = p38.DeliveryPrice, + TaxesPrice = p38.TaxesPrice, + ServicePrice = p38.ServicePrice, + PackingPrice = p38.PackingPrice, + TotalProductsPrice = p38.TotalProductsPrice, + DiscountPrice = p38.DiscountPrice, + DiscountCodePrice = p38.DiscountCodePrice, + ProductDiscountPrice = p38.ProductDiscountPrice, + IsPayed = p38.IsPayed, + OrderStatus = p38.OrderStatus, + PayedAt = p38.PayedAt, + DoneAt = p38.DoneAt, + OrderAt = p38.OrderAt, + PreparingMinute = p38.PreparingMinute, + DiscountCode = p38.DiscountCode, + CustomerFullName = p38.Customer != null && p38.Customer.User != null ? p38.Customer.User.FirstName + " " + p38.Customer.User.LastName : string.Empty, + CustomerPhoneNumber = p38.Customer != null && p38.Customer.User != null ? p38.Customer.User.PhoneNumber : string.Empty, + CustomerId = p38.CustomerId, + Id = p38.Id, + CreatedAt = p38.CreatedAt }; } - public static OrderSDto AdaptTo(this Order p41, OrderSDto p42) + public static OrderSDto AdaptTo(this Order p39, OrderSDto p40) { - if (p41 == null) + if (p39 == null) { return null; } - OrderSDto result = p42 ?? new OrderSDto(); + OrderSDto result = p40 ?? new OrderSDto(); - result.TotalPrice = p41.TotalPrice; - result.FactorCode = p41.FactorCode; - result.DeliveryPrice = p41.DeliveryPrice; - result.TaxesPrice = p41.TaxesPrice; - result.ServicePrice = p41.ServicePrice; - result.PackingPrice = p41.PackingPrice; - result.TotalProductsPrice = p41.TotalProductsPrice; - result.DiscountPrice = p41.DiscountPrice; - result.DiscountCodePrice = p41.DiscountCodePrice; - result.ProductDiscountPrice = p41.ProductDiscountPrice; - result.IsPayed = p41.IsPayed; - result.OrderStatus = p41.OrderStatus; - result.PayedAt = p41.PayedAt; - result.DoneAt = p41.DoneAt; - result.OrderAt = p41.OrderAt; - result.PreparingMinute = p41.PreparingMinute; - result.DiscountCode = p41.DiscountCode; - result.UserFullName = p41.User != null ? p41.User.FirstName + " " + p41.User.LastName : string.Empty; - result.UserPhoneNumber = p41.User != null ? p41.User.PhoneNumber : string.Empty; - result.UserId = p41.UserId; - result.Id = p41.Id; - result.CreatedAt = p41.CreatedAt; + result.TotalPrice = p39.TotalPrice; + result.FactorCode = p39.FactorCode; + result.DeliveryPrice = p39.DeliveryPrice; + result.TaxesPrice = p39.TaxesPrice; + result.ServicePrice = p39.ServicePrice; + result.PackingPrice = p39.PackingPrice; + result.TotalProductsPrice = p39.TotalProductsPrice; + result.DiscountPrice = p39.DiscountPrice; + result.DiscountCodePrice = p39.DiscountCodePrice; + result.ProductDiscountPrice = p39.ProductDiscountPrice; + result.IsPayed = p39.IsPayed; + result.OrderStatus = p39.OrderStatus; + result.PayedAt = p39.PayedAt; + result.DoneAt = p39.DoneAt; + result.OrderAt = p39.OrderAt; + result.PreparingMinute = p39.PreparingMinute; + result.DiscountCode = p39.DiscountCode; + result.CustomerFullName = p39.Customer != null && p39.Customer.User != null ? p39.Customer.User.FirstName + " " + p39.Customer.User.LastName : string.Empty; + result.CustomerPhoneNumber = p39.Customer != null && p39.Customer.User != null ? p39.Customer.User.PhoneNumber : string.Empty; + result.CustomerId = p39.CustomerId; + result.Id = p39.Id; + result.CreatedAt = p39.CreatedAt; return result; } - public static Expression> ProjectToSDto => p43 => new OrderSDto() + public static Expression> ProjectToSDto => p41 => new OrderSDto() { - TotalPrice = p43.TotalPrice, - FactorCode = p43.FactorCode, - DeliveryPrice = p43.DeliveryPrice, - TaxesPrice = p43.TaxesPrice, - ServicePrice = p43.ServicePrice, - PackingPrice = p43.PackingPrice, - TotalProductsPrice = p43.TotalProductsPrice, - DiscountPrice = p43.DiscountPrice, - DiscountCodePrice = p43.DiscountCodePrice, - ProductDiscountPrice = p43.ProductDiscountPrice, - IsPayed = p43.IsPayed, - OrderStatus = p43.OrderStatus, - PayedAt = p43.PayedAt, - DoneAt = p43.DoneAt, - OrderAt = p43.OrderAt, - PreparingMinute = p43.PreparingMinute, - DiscountCode = p43.DiscountCode, - UserFullName = p43.User != null ? p43.User.FirstName + " " + p43.User.LastName : string.Empty, - UserPhoneNumber = p43.User != null ? p43.User.PhoneNumber : string.Empty, - UserId = p43.UserId, - Id = p43.Id, - CreatedAt = p43.CreatedAt + TotalPrice = p41.TotalPrice, + FactorCode = p41.FactorCode, + DeliveryPrice = p41.DeliveryPrice, + TaxesPrice = p41.TaxesPrice, + ServicePrice = p41.ServicePrice, + PackingPrice = p41.PackingPrice, + TotalProductsPrice = p41.TotalProductsPrice, + DiscountPrice = p41.DiscountPrice, + DiscountCodePrice = p41.DiscountCodePrice, + ProductDiscountPrice = p41.ProductDiscountPrice, + IsPayed = p41.IsPayed, + OrderStatus = p41.OrderStatus, + PayedAt = p41.PayedAt, + DoneAt = p41.DoneAt, + OrderAt = p41.OrderAt, + PreparingMinute = p41.PreparingMinute, + DiscountCode = p41.DiscountCode, + CustomerFullName = p41.Customer != null && p41.Customer.User != null ? p41.Customer.User.FirstName + " " + p41.Customer.User.LastName : string.Empty, + CustomerPhoneNumber = p41.Customer != null && p41.Customer.User != null ? p41.Customer.User.PhoneNumber : string.Empty, + CustomerId = p41.CustomerId, + Id = p41.Id, + CreatedAt = p41.CreatedAt }; private static List funcMain1(List p2) @@ -540,12 +518,6 @@ namespace NetinaShop.Domain.Mappers Status = item.Status, OrderId = item.OrderId, Order = new Order() {Id = item.OrderId}, - UserId = item.UserId, - User = new ApplicationUser() - { - Id = item.UserId, - PhoneNumber = item.UserPhoneNumber - }, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -555,51 +527,42 @@ namespace NetinaShop.Domain.Mappers } - private static ApplicationUser funcMain3(Never p6, ApplicationUser p7, OrderLDto p4) + private static OrderDelivery funcMain3(OrderDeliverySDto p6, OrderDelivery p7) { - ApplicationUser result = p7 ?? new ApplicationUser(); + if (p6 == null) + { + return null; + } + OrderDelivery result = p7 ?? new OrderDelivery(); - result.PhoneNumber = p4.UserPhoneNumber; + result.AddressId = p6.AddressId; + result.Address = p6.Address == null ? null : (UserAddress)Convert.ChangeType((object)p6.Address, typeof(UserAddress)); + result.DeliveryCost = p6.DeliveryCost; + result.TrackingCode = p6.TrackingCode; + result.ShippingId = p6.ShippingId; + result.Shipping = funcMain4(new Never(), result.Shipping, p6); + result.OrderId = p6.OrderId; + result.Order = funcMain5(new Never(), result.Order, p6); + result.Id = p6.Id; + result.CreatedAt = p6.CreatedAt; return result; } - private static OrderDelivery funcMain4(OrderDeliverySDto p8, OrderDelivery p9) + private static List funcMain6(List p12, List p13) { - if (p8 == null) + if (p12 == null) { return null; } - OrderDelivery result = p9 ?? new OrderDelivery(); - - result.AddressId = p8.AddressId; - result.Address = p8.Address == null ? null : (UserAddress)Convert.ChangeType((object)p8.Address, typeof(UserAddress)); - result.DeliveryCost = p8.DeliveryCost; - result.TrackingCode = p8.TrackingCode; - result.ShippingId = p8.ShippingId; - result.Shipping = funcMain5(new Never(), result.Shipping, p8); - result.OrderId = p8.OrderId; - result.Order = funcMain6(new Never(), result.Order, p8); - result.Id = p8.Id; - result.CreatedAt = p8.CreatedAt; - return result; - - } - - private static List funcMain7(List p14, List p15) - { - if (p14 == null) - { - return null; - } - List result = new List(p14.Count); + List result = new List(p12.Count); int i = 0; - int len = p14.Count; + int len = p12.Count; while (i < len) { - OrderProductSDto item = p14[i]; + OrderProductSDto item = p12[i]; result.Add(item == null ? null : new OrderProduct() { Count = item.Count, @@ -627,20 +590,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain8(List p16, List p17) + private static List funcMain7(List p14, List p15) { - if (p16 == null) + if (p14 == null) { return null; } - List result = new List(p16.Count); + List result = new List(p14.Count); int i = 0; - int len = p16.Count; + int len = p14.Count; while (i < len) { - PaymentSDto item = p16[i]; + PaymentSDto item = p14[i]; result.Add(item == null ? null : new Payment() { FactorNumber = item.FactorNumber, @@ -653,12 +616,6 @@ namespace NetinaShop.Domain.Mappers Status = item.Status, OrderId = item.OrderId, Order = new Order() {Id = item.OrderId}, - UserId = item.UserId, - User = new ApplicationUser() - { - Id = item.UserId, - PhoneNumber = item.UserPhoneNumber - }, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -668,20 +625,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain9(List p22) + private static List funcMain8(List p20) { - if (p22 == null) + if (p20 == null) { return null; } - List result = new List(p22.Count); + List result = new List(p20.Count); int i = 0; - int len = p22.Count; + int len = p20.Count; while (i < len) { - OrderProduct item = p22[i]; + OrderProduct item = p20[i]; result.Add(item == null ? null : new OrderProductSDto() { Count = item.Count, @@ -704,20 +661,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain10(List p23) + private static List funcMain9(List p21) { - if (p23 == null) + if (p21 == null) { return null; } - List result = new List(p23.Count); + List result = new List(p21.Count); int i = 0; - int len = p23.Count; + int len = p21.Count; while (i < len) { - Payment item = p23[i]; + Payment item = p21[i]; result.Add(item == null ? null : new PaymentSDto() { FactorNumber = item.FactorNumber, @@ -729,9 +686,6 @@ namespace NetinaShop.Domain.Mappers Type = item.Type, Status = item.Status, OrderId = item.OrderId, - UserId = item.UserId, - UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, - UserPhoneNumber = item.User != null ? item.User.PhoneNumber : string.Empty, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -741,56 +695,56 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain11(List p26, List p27) + private static List funcMain10(List p24, List p25) + { + if (p24 == null) + { + return null; + } + List result = new List(p24.Count); + + int i = 0; + int len = p24.Count; + + while (i < len) + { + OrderProduct item = p24[i]; + result.Add(item == null ? null : new OrderProductSDto() + { + Count = item.Count, + ProductFee = item.ProductFee, + ProductFeeWithDiscount = item.ProductFeeWithDiscount, + HasDiscount = item.HasDiscount, + ProductCost = item.ProductCost, + PackingFee = item.PackingFee, + PackingCost = item.PackingCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + ProductName = item.Product != null ? item.Product.PersianName : string.Empty, + OrderId = item.OrderId, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain11(List p26, List p27) { if (p26 == null) { return null; } - List result = new List(p26.Count); + List result = new List(p26.Count); int i = 0; int len = p26.Count; while (i < len) { - OrderProduct item = p26[i]; - result.Add(item == null ? null : new OrderProductSDto() - { - Count = item.Count, - ProductFee = item.ProductFee, - ProductFeeWithDiscount = item.ProductFeeWithDiscount, - HasDiscount = item.HasDiscount, - ProductCost = item.ProductCost, - PackingFee = item.PackingFee, - PackingCost = item.PackingCost, - OrderProductStatus = item.OrderProductStatus, - ProductId = item.ProductId, - ProductName = item.Product != null ? item.Product.PersianName : string.Empty, - OrderId = item.OrderId, - Id = item.Id, - CreatedAt = item.CreatedAt - }); - i++; - } - return result; - - } - - private static List funcMain12(List p28, List p29) - { - if (p28 == null) - { - return null; - } - List result = new List(p28.Count); - - int i = 0; - int len = p28.Count; - - while (i < len) - { - Payment item = p28[i]; + Payment item = p26[i]; result.Add(item == null ? null : new PaymentSDto() { FactorNumber = item.FactorNumber, @@ -802,9 +756,6 @@ namespace NetinaShop.Domain.Mappers Type = item.Type, Status = item.Status, OrderId = item.OrderId, - UserId = item.UserId, - UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, - UserPhoneNumber = item.User != null ? item.User.PhoneNumber : string.Empty, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -814,59 +765,58 @@ namespace NetinaShop.Domain.Mappers } - private static OrderDeliverySDto funcMain13(OrderDelivery p30, OrderDeliverySDto p31) + private static OrderDeliverySDto funcMain12(OrderDelivery p28, OrderDeliverySDto p29) { - if (p30 == null) + if (p28 == null) { return null; } - OrderDeliverySDto result = p31 ?? new OrderDeliverySDto(); + OrderDeliverySDto result = p29 ?? new OrderDeliverySDto(); - result.Province = p30.Address != null ? p30.Address.Province : string.Empty; - result.City = p30.Address != null ? p30.Address.City : string.Empty; - result.Plaque = p30.Address != null ? p30.Address.Plaque : string.Empty; - result.LocationLat = p30.Address != null ? p30.Address.LocationLat : 0f; - result.LocationLong = p30.Address != null ? p30.Address.LocationLong : 0f; - result.Address = p30.Address != null ? p30.Address.Address : string.Empty; - result.PostalCode = p30.Address != null ? p30.Address.PostalCode : string.Empty; - result.TrackingCode = p30.TrackingCode; - result.ReceiverPhoneNumber = p30.Address != null ? p30.Address.ReceiverPhoneNumber : string.Empty; - result.ReceiverFullName = p30.Address != null ? p30.Address.ReceiverFullName : string.Empty; - result.ShippingMethod = p30.Shipping != null ? p30.Shipping.Name : string.Empty; - result.DeliveryCost = p30.DeliveryCost; - result.AddressId = p30.AddressId; - result.OrderId = p30.OrderId; - result.ShippingId = p30.ShippingId; - result.Id = p30.Id; - result.CreatedAt = p30.CreatedAt; + result.Province = p28.Address != null ? p28.Address.Province : string.Empty; + result.City = p28.Address != null ? p28.Address.City : string.Empty; + result.Plaque = p28.Address != null ? p28.Address.Plaque : string.Empty; + result.LocationLat = p28.Address != null ? p28.Address.LocationLat : 0f; + result.LocationLong = p28.Address != null ? p28.Address.LocationLong : 0f; + result.Address = p28.Address != null ? p28.Address.Address : string.Empty; + result.PostalCode = p28.Address != null ? p28.Address.PostalCode : string.Empty; + result.TrackingCode = p28.TrackingCode; + result.ReceiverPhoneNumber = p28.Address != null ? p28.Address.ReceiverPhoneNumber : string.Empty; + result.ReceiverFullName = p28.Address != null ? p28.Address.ReceiverFullName : string.Empty; + result.ShippingMethod = p28.Shipping != null ? p28.Shipping.Name : string.Empty; + result.DeliveryCost = p28.DeliveryCost; + result.AddressId = p28.AddressId; + result.OrderId = p28.OrderId; + result.ShippingId = p28.ShippingId; + result.Id = p28.Id; + result.CreatedAt = p28.CreatedAt; return result; } - private static ApplicationUser funcMain14(Never p38, ApplicationUser p39, OrderSDto p36) + private static Customer funcMain13(Never p36, Customer p37, OrderSDto p34) { - ApplicationUser result = p39 ?? new ApplicationUser(); + Customer result = p37 ?? new Customer(); - result.Id = p36.UserId; - result.PhoneNumber = p36.UserPhoneNumber; + result.Id = p34.CustomerId; return result; } - private static Shipping funcMain5(Never p10, Shipping p11, OrderDeliverySDto p8) + private static Shipping funcMain4(Never p8, Shipping p9, OrderDeliverySDto p6) { - Shipping result = p11 ?? new Shipping(); + Shipping result = p9 ?? new Shipping(); - result.Id = p8.ShippingId; + result.Id = p6.ShippingId; return result; } - private static Order funcMain6(Never p12, Order p13, OrderDeliverySDto p8) + private static Order funcMain5(Never p10, Order p11, OrderDeliverySDto p6) { - Order result = p13 ?? new Order(); + Order result = p11 ?? new Order(); - result.Id = p8.OrderId; + result.Id = p6.OrderId; return result; } diff --git a/NetinaShop.Domain/Mappers/PaymentMapper.g.cs b/NetinaShop.Domain/Mappers/PaymentMapper.g.cs index f79b9a9..4ceff13 100644 --- a/NetinaShop.Domain/Mappers/PaymentMapper.g.cs +++ b/NetinaShop.Domain/Mappers/PaymentMapper.g.cs @@ -4,7 +4,6 @@ using Mapster.Models; using NetinaShop.Domain.Dtos.SmallDtos; using NetinaShop.Domain.Entities.Accounting; using NetinaShop.Domain.Entities.Orders; -using NetinaShop.Domain.Entities.Users; namespace NetinaShop.Domain.Mappers { @@ -24,12 +23,6 @@ namespace NetinaShop.Domain.Mappers Status = p1.Status, OrderId = p1.OrderId, Order = new Order() {Id = p1.OrderId}, - UserId = p1.UserId, - User = new ApplicationUser() - { - Id = p1.UserId, - PhoneNumber = p1.UserPhoneNumber - }, Id = p1.Id, CreatedAt = p1.CreatedAt }; @@ -52,74 +45,63 @@ namespace NetinaShop.Domain.Mappers result.Status = p2.Status; result.OrderId = p2.OrderId; result.Order = funcMain1(new Never(), result.Order, p2); - result.UserId = p2.UserId; - result.User = funcMain2(new Never(), result.User, p2); result.Id = p2.Id; result.CreatedAt = p2.CreatedAt; return result; } - public static PaymentSDto AdaptToSDto(this Payment p8) + public static PaymentSDto AdaptToSDto(this Payment p6) { - return p8 == null ? null : new PaymentSDto() + return p6 == null ? null : new PaymentSDto() { - FactorNumber = p8.FactorNumber, - Amount = p8.Amount, - Description = p8.Description, - TransactionCode = p8.TransactionCode, - CardPan = p8.CardPan, - Authority = p8.Authority, - Type = p8.Type, - Status = p8.Status, - OrderId = p8.OrderId, - UserId = p8.UserId, - UserFullName = p8.User != null ? p8.User.FirstName + " " + p8.User.LastName : string.Empty, - UserPhoneNumber = p8.User != null ? p8.User.PhoneNumber : string.Empty, - Id = p8.Id, - CreatedAt = p8.CreatedAt + FactorNumber = p6.FactorNumber, + Amount = p6.Amount, + Description = p6.Description, + TransactionCode = p6.TransactionCode, + CardPan = p6.CardPan, + Authority = p6.Authority, + Type = p6.Type, + Status = p6.Status, + OrderId = p6.OrderId, + Id = p6.Id, + CreatedAt = p6.CreatedAt }; } - public static PaymentSDto AdaptTo(this Payment p9, PaymentSDto p10) + public static PaymentSDto AdaptTo(this Payment p7, PaymentSDto p8) { - if (p9 == null) + if (p7 == null) { return null; } - PaymentSDto result = p10 ?? new PaymentSDto(); + PaymentSDto result = p8 ?? new PaymentSDto(); - result.FactorNumber = p9.FactorNumber; - result.Amount = p9.Amount; - result.Description = p9.Description; - result.TransactionCode = p9.TransactionCode; - result.CardPan = p9.CardPan; - result.Authority = p9.Authority; - result.Type = p9.Type; - result.Status = p9.Status; - result.OrderId = p9.OrderId; - result.UserId = p9.UserId; - result.UserFullName = p9.User != null ? p9.User.FirstName + " " + p9.User.LastName : string.Empty; - result.UserPhoneNumber = p9.User != null ? p9.User.PhoneNumber : string.Empty; - result.Id = p9.Id; - result.CreatedAt = p9.CreatedAt; + result.FactorNumber = p7.FactorNumber; + result.Amount = p7.Amount; + result.Description = p7.Description; + result.TransactionCode = p7.TransactionCode; + result.CardPan = p7.CardPan; + result.Authority = p7.Authority; + result.Type = p7.Type; + result.Status = p7.Status; + result.OrderId = p7.OrderId; + result.Id = p7.Id; + result.CreatedAt = p7.CreatedAt; return result; } - public static Expression> ProjectToSDto => p11 => new PaymentSDto() + public static Expression> ProjectToSDto => p9 => new PaymentSDto() { - FactorNumber = p11.FactorNumber, - Amount = p11.Amount, - Description = p11.Description, - TransactionCode = p11.TransactionCode, - CardPan = p11.CardPan, - Authority = p11.Authority, - Type = p11.Type, - Status = p11.Status, - OrderId = p11.OrderId, - UserId = p11.UserId, - UserFullName = p11.User != null ? p11.User.FirstName + " " + p11.User.LastName : string.Empty, - UserPhoneNumber = p11.User != null ? p11.User.PhoneNumber : string.Empty, - Id = p11.Id, - CreatedAt = p11.CreatedAt + FactorNumber = p9.FactorNumber, + Amount = p9.Amount, + Description = p9.Description, + TransactionCode = p9.TransactionCode, + CardPan = p9.CardPan, + Authority = p9.Authority, + Type = p9.Type, + Status = p9.Status, + OrderId = p9.OrderId, + Id = p9.Id, + CreatedAt = p9.CreatedAt }; private static Order funcMain1(Never p4, Order p5, PaymentSDto p2) @@ -130,15 +112,5 @@ namespace NetinaShop.Domain.Mappers return result; } - - private static ApplicationUser funcMain2(Never p6, ApplicationUser p7, PaymentSDto p2) - { - ApplicationUser result = p7 ?? new ApplicationUser(); - - result.Id = p2.UserId; - result.PhoneNumber = p2.UserPhoneNumber; - return result; - - } } } \ No newline at end of file diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs index 87ab647..c8b137f 100644 --- a/NetinaShop.Domain/MapsterRegister.cs +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -35,14 +35,14 @@ public class MapsterRegister : IRegister .TwoWays(); config.NewConfig() - .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) - .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) + .Map("CustomerFullName", o => o.Customer != null && o.Customer.User != null ? o.Customer.User.FirstName + " " + o.Customer.User.LastName : string.Empty) + .Map("CustomerPhoneNumber", o => o.Customer != null && o.Customer.User != null ? o.Customer.User.PhoneNumber : string.Empty) .IgnoreNullValues(false) .TwoWays(); config.NewConfig() - .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) - .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) + .Map("CustomerFullName", o => o.Customer != null && o.Customer.User != null ? o.Customer.User.FirstName + " " + o.Customer.User.LastName : string.Empty) + .Map("CustomerPhoneNumber", o => o.Customer != null && o.Customer.User != null ? o.Customer.User.PhoneNumber : string.Empty) .IgnoreNullValues(false) .TwoWays(); @@ -66,8 +66,8 @@ public class MapsterRegister : IRegister .TwoWays(); config.NewConfig() - .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) - .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) + .Map("CustomerFullName", o => o.Customer != null && o.Customer.User != null ? o.Customer.User.FirstName + " " + o.Customer.User.LastName : string.Empty) + .Map("CustomerPhoneNumber", o => o.Customer != null && o.Customer.User != null ? o.Customer.User.PhoneNumber : string.Empty) .IgnoreNullValues(false) .TwoWays(); diff --git a/NetinaShop.Domain/Models/Claims/ApplicationClaims.cs b/NetinaShop.Domain/Models/Claims/ApplicationClaims.cs index d425772..a7c0943 100644 --- a/NetinaShop.Domain/Models/Claims/ApplicationClaims.cs +++ b/NetinaShop.Domain/Models/Claims/ApplicationClaims.cs @@ -4,6 +4,12 @@ namespace NetinaShop.Domain.Models.Claims; public static class ApplicationClaims { + public static ClaimDto ManageDashboard { get; } = new ClaimDto + { + Title = "مدیریت داشبورد", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ManageDashboard, + }; public static ClaimDto ManageBlogs { get; } = new ClaimDto { @@ -177,9 +183,75 @@ public static class ApplicationClaims Type = CustomClaimType.Permission, Value = ApplicationPermission.ViewFiles, }; + public static ClaimDto ViewNewsletterMembers { get; } = new ClaimDto + { + Title = "مشاهده اعضا خبرنامه ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ViewNewsletterMembers, + }; + public static ClaimDto ManagePages { get; } = new ClaimDto + { + Title = "مدیریت صفحه ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ManagePages, + }; + public static ClaimDto ViewPages { get; } = new ClaimDto + { + Title = "مشاهده صفحه ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ViewPages, + }; + public static ClaimDto ViewPayments { get; } = new ClaimDto + { + Title = "مشاهده پرداخت ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ViewPayments, + }; + + public static ClaimDto ViewRoles { get; } = new ClaimDto + { + Title = "مشاهده نقش ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ViewRoles, + }; + public static ClaimDto ManageRoles { get; } = new ClaimDto + { + Title = "مدیریت نقش ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ManageRoles, + }; + public static ClaimDto ManageScraper { get; } = new ClaimDto + { + Title = "مدیریت خزنده ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ManageScraper, + }; + + public static ClaimDto ManageSettings { get; } = new ClaimDto + { + Title = "مدیریت تنظیمات ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ManageSettings, + }; + public static ClaimDto ViewSettings { get; } = new ClaimDto + { + Title = "مشاهده تنظیمات ها", + Type = CustomClaimType.Permission, + Value = ApplicationPermission.ViewSettings, + }; public static List AllClaimDtos = new List { + ViewSettings, + ManageSettings, + ManageScraper, + ViewRoles, + ManageRoles, + ViewPayments, + ViewPages, + ManagePages, + ViewNewsletterMembers, + ManageDashboard, ManageBlogs, ViewBlogs, ManageBrands, @@ -211,6 +283,16 @@ public static class ApplicationClaims public static List AllClaims = new List { + ViewSettings.GetClaim, + ManageSettings.GetClaim, + ManageScraper.GetClaim, + ViewRoles.GetClaim, + ManageRoles.GetClaim, + ViewPayments.GetClaim, + ViewPages.GetClaim, + ManagePages.GetClaim, + ViewNewsletterMembers.GetClaim, + ManageDashboard.GetClaim, ManageBlogs.GetClaim, ViewBlogs.GetClaim, ManageBrands.GetClaim, diff --git a/NetinaShop.Domain/Models/Claims/ApplicationPermission.cs b/NetinaShop.Domain/Models/Claims/ApplicationPermission.cs index 4d2e504..ae1e66e 100644 --- a/NetinaShop.Domain/Models/Claims/ApplicationPermission.cs +++ b/NetinaShop.Domain/Models/Claims/ApplicationPermission.cs @@ -2,6 +2,21 @@ public static class ApplicationPermission { + public const string ViewSettings = nameof(ViewSettings); + public const string ManageSettings = nameof(ManageSettings); + + public const string ManageScraper = nameof(ManageScraper); + + public const string ViewRoles = nameof(ViewRoles); + public const string ManageRoles = nameof(ManageRoles); + + public const string ViewPayments = nameof(ViewPayments); + + public const string ViewNewsletterMembers = nameof(ViewNewsletterMembers); + + public const string ViewPages = nameof(ViewPages); + public const string ManagePages = nameof(ManagePages); + public const string ManageBlogs = nameof(ManageBlogs); public const string ViewBlogs = nameof(ViewBlogs); @@ -39,4 +54,6 @@ public static class ApplicationPermission public const string ManageFiles = nameof(ManageFiles); public const string ViewFiles = nameof(ViewFiles); + + public const string ManageDashboard = nameof(ManageDashboard); } \ No newline at end of file diff --git a/NetinaShop.Infrastructure/Services/ZarinpalService.cs b/NetinaShop.Infrastructure/Services/ZarinpalService.cs index 42af09c..bdb1296 100644 --- a/NetinaShop.Infrastructure/Services/ZarinpalService.cs +++ b/NetinaShop.Infrastructure/Services/ZarinpalService.cs @@ -78,7 +78,7 @@ public class ZarinpalService : IPaymentService await _mediator.Send(new CreateOrUpdatePaymentCommand(payment.Id, payment.FactorNumber, payment.Amount, payment.Description, payment.TransactionCode, payment.CardPan, payment.Authority, payment.Type, payment.Status, - payment.OrderId, payment.UserId), cancellationToken); + payment.OrderId, payment.CustomerId), cancellationToken); await _mediator.Send(new SubmitOrderPaymentCommand(payment.OrderId, OrderPaymentMethod.OnlinePayment, true), cancellationToken); diff --git a/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs b/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs index 0c075ce..bcf0fe2 100644 --- a/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs @@ -1,4 +1,5 @@ -using NetinaShop.Domain.Entities.Orders; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.Entities.Orders; namespace NetinaShop.Repository.Handlers.Orders; @@ -13,9 +14,21 @@ public class CreateBaseOrderCommandHandler : IRequestHandler Handle(CreateBaseOrderCommand request, CancellationToken cancellationToken) { if (request.UserId == default) - throw new AppException("User id is null"); - - var order = Order.Create(request.UserId); + throw new AppException("Customer id is null"); + var customer = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(c => c.UserId == request.UserId, cancellationToken); + if (customer == null) + { + customer = new Customer + { + UserId = request.UserId + }; + _repositoryWrapper.SetRepository() + .Add(customer); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + var order = Order.Create(customer.Id); _repositoryWrapper.SetRepository() .Add(order); diff --git a/NetinaShop.Repository/Handlers/Orders/GetUserOrdersQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetUserOrdersQueryHandler.cs index b44fee7..cf700ac 100644 --- a/NetinaShop.Repository/Handlers/Orders/GetUserOrdersQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/GetUserOrdersQueryHandler.cs @@ -15,20 +15,26 @@ public class GetUserOrdersQueryHandler : IRequestHandler> Handle(GetUserOrdersQuery request, CancellationToken cancellationToken) { - Guid userId = Guid.Empty; - if (request.UserId == default) + Guid customerId = Guid.Empty; + if (request.CustomerId == default) { if (_currentUserService.UserId == null) throw new AppException("Token is wrong", ApiResultStatusCode.UnAuthorized); - if (!Guid.TryParse(_currentUserService.UserId, out userId)) + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) throw new AppException("Token is wrong", ApiResultStatusCode.UnAuthorized); + var customer = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(c => c.UserId == userId, cancellationToken); + if (customer == null) + throw new AppException("User is not a customer"); + customerId = customer.Id; } else - userId = request.UserId; + customerId = request.CustomerId; var orders = await _repositoryWrapper.SetRepository() .TableNoTracking - .Where(o => o.UserId == userId) + .Where(o => o.CustomerId == customerId) .Select(OrderMapper.ProjectToSDto) .ToListAsync(cancellationToken); diff --git a/NetinaShop.Repository/Migrations/20240415174511_AddNewUserEntites.Designer.cs b/NetinaShop.Repository/Migrations/20240415174511_AddNewUserEntites.Designer.cs new file mode 100644 index 0000000..dafc35e --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240415174511_AddNewUserEntites.Designer.cs @@ -0,0 +1,1936 @@ +// +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("20240415174511_AddNewUserEntites")] + partial class AddNewUserEntites + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("double precision"); + + b.Property("Authority") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardPan") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FactorNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TransactionCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("CorporateUserId") + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("Immortal") + .HasColumnType("boolean"); + + b.Property("IsForFirstPurchase") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsForSaleCooperation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CorporateUserId"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveredAt") + .HasColumnType("timestamp without time zone"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountCodePrice") + .HasColumnType("double precision"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("ProductDiscountPrice") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("DiscountId"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddressId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ShippingId") + .HasColumnType("uuid"); + + b.Property("TrackingCode") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("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.Customer", 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("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", 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("LatestVersionUsed") + .HasColumnType("double precision"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .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") + .IsUnique(); + + b.ToTable("Managers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("FatherName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Shaba") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Marketers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.NewsletterMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("NewsletterMembers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingUnit") + .IsRequired() + .HasColumnType("text"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + 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("CustomerId"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFavoriteProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsExpressShipping") + .HasColumnType("boolean"); + + b.Property("IsOriginalWarehouse") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsShipBySeller") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkingDays") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Shippings", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("CategoryDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.HasIndex("BrandId"); + + b.HasDiscriminator().HasValue("BrandStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("ProductCategoryStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductStorageFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "CorporateUser") + .WithMany() + .HasForeignKey("CorporateUserId"); + + b.Navigation("CorporateUser"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null) + .WithMany("Orders") + .HasForeignKey("DiscountId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithOne("OrderDelivery") + .HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Address"); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Customer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Customer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Manager") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Manager", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Marketer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Marketer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", null) + .WithMany("Addresses") + .HasForeignKey("CustomerId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDelivery"); + + b.Navigation("OrderProducts"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Customer"); + + b.Navigation("Manager"); + + b.Navigation("Marketer"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240415174511_AddNewUserEntites.cs b/NetinaShop.Repository/Migrations/20240415174511_AddNewUserEntites.cs new file mode 100644 index 0000000..81c94ec --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240415174511_AddNewUserEntites.cs @@ -0,0 +1,1236 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class AddNewUserEntites : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Users_UserId", + schema: "public", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "LatestVersionUsed", + schema: "public", + table: "Users"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "UserFavoriteProducts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "UserFavoriteProducts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "UserFavoriteProducts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AddColumn( + name: "CustomerId", + schema: "public", + table: "UserAddresses", + type: "uuid", + nullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "StorageFiles", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "StorageFiles", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "StorageFiles", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Specifications", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Specifications", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Specifications", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Shippings", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Shippings", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Shippings", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Reviews", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Reviews", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Reviews", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Products", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Products", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Products", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ProductCategories", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ProductCategories", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ProductCategories", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Payments", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Payments", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Payments", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Orders", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Orders", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Orders", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "OrderProducts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "OrderProducts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "OrderProducts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "NewsletterMembers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "NewsletterMembers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "NewsletterMembers", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Discounts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Discounts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Discounts", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Brands", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Brands", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Brands", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Blogs", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Blogs", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Blogs", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "BlogCategories", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "BlogCategories", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "BlogCategories", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.CreateTable( + name: "Customers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Customers", x => x.Id); + table.ForeignKey( + name: "FK_Customers_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Managers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + LatestVersionUsed = table.Column(type: "double precision", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Managers", x => x.Id); + table.ForeignKey( + name: "FK_Managers_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Marketers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + FatherName = table.Column(type: "text", nullable: false), + Shaba = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Marketers", x => x.Id); + table.ForeignKey( + name: "FK_Marketers_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_UserAddresses_CustomerId", + schema: "public", + table: "UserAddresses", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_Customers_UserId", + schema: "public", + table: "Customers", + column: "UserId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Managers_UserId", + schema: "public", + table: "Managers", + column: "UserId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Marketers_UserId", + schema: "public", + table: "Marketers", + column: "UserId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Customers_UserId", + schema: "public", + table: "Orders", + column: "UserId", + principalSchema: "public", + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_UserAddresses_Customers_CustomerId", + schema: "public", + table: "UserAddresses", + column: "CustomerId", + principalSchema: "public", + principalTable: "Customers", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Customers_UserId", + schema: "public", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_UserAddresses_Customers_CustomerId", + schema: "public", + table: "UserAddresses"); + + migrationBuilder.DropTable( + name: "Customers", + schema: "public"); + + migrationBuilder.DropTable( + name: "Managers", + schema: "public"); + + migrationBuilder.DropTable( + name: "Marketers", + schema: "public"); + + migrationBuilder.DropIndex( + name: "IX_UserAddresses_CustomerId", + schema: "public", + table: "UserAddresses"); + + migrationBuilder.DropColumn( + name: "CustomerId", + schema: "public", + table: "UserAddresses"); + + migrationBuilder.AddColumn( + name: "LatestVersionUsed", + schema: "public", + table: "Users", + type: "double precision", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "UserFavoriteProducts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "UserFavoriteProducts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "UserFavoriteProducts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "UserAddresses", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "StorageFiles", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "StorageFiles", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "StorageFiles", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Specifications", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Specifications", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Specifications", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Shippings", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Shippings", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Shippings", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Reviews", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Reviews", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Reviews", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Products", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Products", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Products", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "ProductCategories", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "ProductCategories", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "ProductCategories", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Payments", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Payments", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Payments", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Orders", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Orders", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Orders", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "OrderProducts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "OrderProducts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "OrderProducts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "OrderDeliveries", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "NewsletterMembers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "NewsletterMembers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "NewsletterMembers", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Discounts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Discounts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Discounts", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Brands", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Brands", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Brands", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "Blogs", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "Blogs", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "Blogs", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RemovedBy", + schema: "public", + table: "BlogCategories", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "public", + table: "BlogCategories", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "public", + table: "BlogCategories", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Users_UserId", + schema: "public", + table: "Orders", + column: "UserId", + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240415180335_ChangeOrderUserIdToCustomerId.Designer.cs b/NetinaShop.Repository/Migrations/20240415180335_ChangeOrderUserIdToCustomerId.Designer.cs new file mode 100644 index 0000000..68133a8 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240415180335_ChangeOrderUserIdToCustomerId.Designer.cs @@ -0,0 +1,1936 @@ +// +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("20240415180335_ChangeOrderUserIdToCustomerId")] + partial class ChangeOrderUserIdToCustomerId + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("double precision"); + + b.Property("Authority") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardPan") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FactorNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TransactionCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("CorporateUserId") + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("Immortal") + .HasColumnType("boolean"); + + b.Property("IsForFirstPurchase") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsForSaleCooperation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CorporateUserId"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DeliveredAt") + .HasColumnType("timestamp without time zone"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountCodePrice") + .HasColumnType("double precision"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("ProductDiscountPrice") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DiscountId"); + + 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.Property("TrackingCode") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("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.Customer", 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("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", 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("LatestVersionUsed") + .HasColumnType("double precision"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .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") + .IsUnique(); + + b.ToTable("Managers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("FatherName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Shaba") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Marketers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.NewsletterMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("NewsletterMembers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingUnit") + .IsRequired() + .HasColumnType("text"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + 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("CustomerId"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFavoriteProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsExpressShipping") + .HasColumnType("boolean"); + + b.Property("IsOriginalWarehouse") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsShipBySeller") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkingDays") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Shippings", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("CategoryDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.HasIndex("BrandId"); + + b.HasDiscriminator().HasValue("BrandStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("ProductCategoryStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductStorageFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "CorporateUser") + .WithMany() + .HasForeignKey("CorporateUserId"); + + b.Navigation("CorporateUser"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null) + .WithMany("Orders") + .HasForeignKey("DiscountId"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithOne("OrderDelivery") + .HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Address"); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Customer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Customer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Manager") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Manager", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Marketer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Marketer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", null) + .WithMany("Addresses") + .HasForeignKey("CustomerId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDelivery"); + + b.Navigation("OrderProducts"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Customer"); + + b.Navigation("Manager"); + + b.Navigation("Marketer"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240415180335_ChangeOrderUserIdToCustomerId.cs b/NetinaShop.Repository/Migrations/20240415180335_ChangeOrderUserIdToCustomerId.cs new file mode 100644 index 0000000..242180b --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240415180335_ChangeOrderUserIdToCustomerId.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class ChangeOrderUserIdToCustomerId : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Customers_UserId", + schema: "public", + table: "Orders"); + + migrationBuilder.RenameColumn( + name: "UserId", + schema: "public", + table: "Orders", + newName: "CustomerId"); + + migrationBuilder.RenameIndex( + name: "IX_Orders_UserId", + schema: "public", + table: "Orders", + newName: "IX_Orders_CustomerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Customers_CustomerId", + schema: "public", + table: "Orders", + column: "CustomerId", + principalSchema: "public", + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Customers_CustomerId", + schema: "public", + table: "Orders"); + + migrationBuilder.RenameColumn( + name: "CustomerId", + schema: "public", + table: "Orders", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_Orders_CustomerId", + schema: "public", + table: "Orders", + newName: "IX_Orders_UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Customers_UserId", + schema: "public", + table: "Orders", + column: "UserId", + principalSchema: "public", + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240415212810_AddCustomerIdToPayment.Designer.cs b/NetinaShop.Repository/Migrations/20240415212810_AddCustomerIdToPayment.Designer.cs new file mode 100644 index 0000000..ba2dc39 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240415212810_AddCustomerIdToPayment.Designer.cs @@ -0,0 +1,1936 @@ +// +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("20240415212810_AddCustomerIdToPayment")] + partial class AddCustomerIdToPayment + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.3") + .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("CustomerId") + .HasColumnType("uuid"); + + 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.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("CorporateUserId") + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("Immortal") + .HasColumnType("boolean"); + + b.Property("IsForFirstPurchase") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsForSaleCooperation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CorporateUserId"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DeliveredAt") + .HasColumnType("timestamp without time zone"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountCodePrice") + .HasColumnType("double precision"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("ProductDiscountPrice") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DiscountId"); + + 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.Property("TrackingCode") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("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.Customer", 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("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", 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("LatestVersionUsed") + .HasColumnType("double precision"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .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") + .IsUnique(); + + b.ToTable("Managers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("FatherName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Shaba") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Marketers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.NewsletterMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("NewsletterMembers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingUnit") + .IsRequired() + .HasColumnType("text"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + 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("CustomerId"); + + 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.Users.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Customer"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "CorporateUser") + .WithMany() + .HasForeignKey("CorporateUserId"); + + b.Navigation("CorporateUser"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null) + .WithMany("Orders") + .HasForeignKey("DiscountId"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithOne("OrderDelivery") + .HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Address"); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Customer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Customer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Manager") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Manager", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Marketer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Marketer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", null) + .WithMany("Addresses") + .HasForeignKey("CustomerId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDelivery"); + + b.Navigation("OrderProducts"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Customer"); + + b.Navigation("Manager"); + + b.Navigation("Marketer"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240415212810_AddCustomerIdToPayment.cs b/NetinaShop.Repository/Migrations/20240415212810_AddCustomerIdToPayment.cs new file mode 100644 index 0000000..27c585c --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240415212810_AddCustomerIdToPayment.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class AddCustomerIdToPayment : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Payments_Users_UserId", + schema: "public", + table: "Payments"); + + migrationBuilder.RenameColumn( + name: "UserId", + schema: "public", + table: "Payments", + newName: "CustomerId"); + + migrationBuilder.RenameIndex( + name: "IX_Payments_UserId", + schema: "public", + table: "Payments", + newName: "IX_Payments_CustomerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Customers_CustomerId", + schema: "public", + table: "Payments", + column: "CustomerId", + principalSchema: "public", + principalTable: "Customers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Payments_Customers_CustomerId", + schema: "public", + table: "Payments"); + + migrationBuilder.RenameColumn( + name: "CustomerId", + schema: "public", + table: "Payments", + newName: "UserId"); + + migrationBuilder.RenameIndex( + name: "IX_Payments_CustomerId", + schema: "public", + table: "Payments", + newName: "IX_Payments_UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Users_UserId", + schema: "public", + table: "Payments", + column: "UserId", + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index ab415d9..f085647 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -147,9 +147,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); + b.Property("CustomerId") + .HasColumnType("uuid"); + b.Property("Description") .IsRequired() .HasColumnType("text"); @@ -165,7 +167,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -175,7 +176,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Status") @@ -188,14 +188,11 @@ namespace NetinaShop.Repository.Migrations b.Property("Type") .HasColumnType("integer"); - b.Property("UserId") - .HasColumnType("uuid"); - b.HasKey("Id"); - b.HasIndex("OrderId"); + b.HasIndex("CustomerId"); - b.HasIndex("UserId"); + b.HasIndex("OrderId"); b.ToTable("Payments", "public"); }); @@ -217,7 +214,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -230,7 +226,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ReadingTime") @@ -240,7 +235,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Summery") @@ -272,7 +266,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -286,7 +279,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -297,7 +289,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -315,7 +306,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -336,7 +326,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PageUrl") @@ -351,7 +340,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -382,7 +370,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -437,7 +424,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PriceCeiling") @@ -450,7 +436,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("StartDate") @@ -483,9 +468,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); + b.Property("CustomerId") + .HasColumnType("uuid"); + b.Property("DeliveredAt") .HasColumnType("timestamp without time zone"); @@ -522,7 +509,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderAt") @@ -550,7 +536,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("ServicePrice") @@ -565,14 +550,11 @@ namespace NetinaShop.Repository.Migrations b.Property("TotalProductsPrice") .HasColumnType("double precision"); - b.Property("UserId") - .HasColumnType("uuid"); - b.HasKey("Id"); - b.HasIndex("DiscountId"); + b.HasIndex("CustomerId"); - b.HasIndex("UserId"); + b.HasIndex("DiscountId"); b.ToTable("Orders", "public"); }); @@ -590,7 +572,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("DeliveryCost") @@ -603,7 +584,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -613,7 +593,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("ShippingId") @@ -648,7 +627,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("HasDiscount") @@ -661,7 +639,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -695,7 +672,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -717,7 +693,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -734,7 +709,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -748,7 +722,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -780,7 +753,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("EnglishName") @@ -807,7 +779,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PackingCost") @@ -824,7 +795,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("ReviewCount") @@ -871,7 +841,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsBuyer") @@ -887,7 +856,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ProductId") @@ -900,7 +868,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Title") @@ -929,7 +896,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Detail") @@ -946,7 +912,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ParentId") @@ -959,7 +924,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Title") @@ -989,7 +953,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Discriminator") @@ -1021,7 +984,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -1032,7 +994,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -1117,9 +1078,6 @@ namespace NetinaShop.Repository.Migrations .IsRequired() .HasColumnType("text"); - b.Property("LatestVersionUsed") - .HasColumnType("double precision"); - b.Property("LockoutEnabled") .HasColumnType("boolean"); @@ -1172,6 +1130,131 @@ namespace NetinaShop.Repository.Migrations b.ToTable("Users", "public"); }); + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", 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("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Customers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", 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("LatestVersionUsed") + .HasColumnType("double precision"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .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") + .IsUnique(); + + b.ToTable("Managers", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("FatherName") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Shaba") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("Marketers", "public"); + }); + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.NewsletterMember", b => { b.Property("Id") @@ -1182,7 +1265,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Email") @@ -1196,7 +1278,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PhoneNumber") @@ -1207,7 +1288,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -1237,9 +1317,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); + b.Property("CustomerId") + .HasColumnType("uuid"); + b.Property("IsRemoved") .HasColumnType("boolean"); @@ -1253,7 +1335,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Plaque") @@ -1280,7 +1361,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("UserId") @@ -1288,6 +1368,8 @@ namespace NetinaShop.Repository.Migrations b.HasKey("Id"); + b.HasIndex("CustomerId"); + b.HasIndex("UserId"); b.ToTable("UserAddresses", "public"); @@ -1303,7 +1385,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -1313,7 +1394,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ProductId") @@ -1323,7 +1403,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("UserId") @@ -1348,7 +1427,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("DeliveryCost") @@ -1370,7 +1448,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -1381,7 +1458,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("WarehouseName") @@ -1515,19 +1591,19 @@ namespace NetinaShop.Repository.Migrations modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict); + 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("Customer"); b.Navigation("Order"); - - b.Navigation("User"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => @@ -1551,16 +1627,16 @@ namespace NetinaShop.Repository.Migrations modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Restrict); + 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"); + b.Navigation("Customer"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => @@ -1663,10 +1739,44 @@ namespace NetinaShop.Repository.Migrations b.Navigation("Product"); }); - modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => { b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Customer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Customer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Manager", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Manager") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Manager", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Marketer", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithOne("Marketer") + .HasForeignKey("NetinaShop.Domain.Entities.Users.Marketer", "UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.Customer", null) .WithMany("Addresses") + .HasForeignKey("CustomerId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1805,6 +1915,15 @@ namespace NetinaShop.Repository.Migrations }); modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Customer"); + + b.Navigation("Manager"); + + b.Navigation("Marketer"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.Customer", b => { b.Navigation("Addresses"); });