From 042c9fb9c752d0aab69ec72bbf42b03d44552c15 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Wed, 20 Dec 2023 10:37:44 +0330 Subject: [PATCH] complete entities complete Dtos , Mappers , CQRS , ApiEndPoints --- .../Controller/BlogCategoryController.cs | 80 ++ NetinaShop.Api/Controller/BlogController.cs | 29 +- NetinaShop.Api/Controller/BrandController.cs | 84 ++ .../Controller/DiscountController.cs | 54 ++ .../Controller/ProductCategoryController.cs | 49 ++ .../Controller/ProductController.cs | 53 ++ .../Controller/ShippingController.cs | 51 ++ NetinaShop.Api/NetinaShop.Api.csproj | 7 + NetinaShop.Common/NetinaShop.Common.csproj | 1 - .../Commands/CategoryCommands.cs | 16 + .../Commands/DiscountCommands.cs | 42 + .../Commands/ProductCommands.cs | 29 + .../Commands/ShippingCommands.cs | 19 + .../CommandQueries/Queries/CategoryQueries.cs | 4 + .../CommandQueries/Queries/DiscountQueries.cs | 4 + .../CommandQueries/Queries/ProductQueries.cs | 5 + .../Dtos/LargDtos/BlogCategoryLDto.cs | 8 + NetinaShop.Domain/Dtos/LargDtos/BlogLDto.cs | 14 + NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs | 13 + .../Dtos/LargDtos/CategoryLDto.cs | 10 + .../Dtos/LargDtos/DiscountLDto.cs | 23 + .../Dtos/LargDtos/ProductLDto.cs | 18 + .../Dtos/SmallDtos/BlogCategorySDto.cs | 7 + NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs | 16 + NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs | 12 + .../Dtos/SmallDtos/CategorySDto.cs | 8 + .../Dtos/SmallDtos/DiscountSDto.cs | 23 + .../Dtos/SmallDtos/ProductCategorySDto.cs | 9 + .../Dtos/SmallDtos/ProductSDto.cs | 14 + .../Dtos/SmallDtos/ReviewSDto.cs | 11 + .../Dtos/SmallDtos/ShippingSDto.cs | 8 + .../Dtos/SmallDtos/SpecificationSDto.cs | 12 + .../Dtos/SmallDtos/StorageFileSDto.cs | 13 + .../Entities/Blogs/Blog.Aggregate.cs | 34 + NetinaShop.Domain/Entities/Blogs/Blog.cs | 21 +- .../Entities/Blogs/BlogCategory.cs | 17 +- .../Entities/Blogs/BlogStorageFile.cs | 11 +- .../Entities/Brands/Brand.Aggregate.cs | 24 + NetinaShop.Domain/Entities/Brands/Brand.cs | 21 +- .../Entities/Brands/BrandStorageFile.cs | 12 +- .../Entities/Categories/Category.Aggregate.cs | 29 + .../Entities/Categories/Category.cs | 21 +- .../Categories/CategoryStorageFile.cs | 12 +- .../Entities/Discounts/CategoryDiscount.cs | 13 +- .../Entities/Discounts/Discount.Aggregate.cs | 31 + .../Entities/Discounts/Discount.cs | 31 +- .../Entities/Discounts/ProductDiscount.cs | 13 +- .../Entities/Products/Product.Aggregate.cs | 64 ++ .../Entities/Products/Product.cs | 27 +- .../Entities/Products/ProductCategory.cs | 21 +- .../Entities/Products/ProductStorageFile.cs | 16 +- NetinaShop.Domain/Entities/Products/Review.cs | 25 +- .../Entities/Products/Specification.cs | 22 +- .../StorageFiles/StorageFile.Aggregate.cs | 9 + .../Entities/StorageFiles/StorageFile.cs | 20 +- .../Entities/Warehouses/Shipping.cs | 21 +- .../Warehouses/Warehouses.Aggregate.cs | 14 + .../Mappers/BlogCategoryMapper.g.cs | 305 ++++++++ NetinaShop.Domain/Mappers/BlogMapper.g.cs | 359 +++++++++ .../Mappers/BlogStorageFileMapper.g.cs | 6 + NetinaShop.Domain/Mappers/BrandMapper.g.cs | 303 ++++++++ .../Mappers/BrandStorageFileMapper.g.cs | 6 + .../Mappers/CategoryDiscountMapper.g.cs | 6 + NetinaShop.Domain/Mappers/CategoryMapper.g.cs | 405 ++++++++++ .../Mappers/CategoryStorageFileMapper.g.cs | 6 + NetinaShop.Domain/Mappers/DiscountMapper.g.cs | 276 +++++++ .../Mappers/ProductCategoryMapper.g.cs | 66 ++ .../Mappers/ProductDiscountMapper.g.cs | 6 + NetinaShop.Domain/Mappers/ProductMapper.g.cs | 734 ++++++++++++++++++ .../Mappers/ProductStorageFileMapper.g.cs | 6 + NetinaShop.Domain/Mappers/ReviewMapper.g.cs | 83 ++ NetinaShop.Domain/Mappers/ShippingMapper.g.cs | 44 ++ .../Mappers/SpecificationMapper.g.cs | 83 ++ .../Mappers/StorageFileMapper.g.cs | 83 ++ NetinaShop.Domain/MappingRegister.cs | 11 - NetinaShop.Domain/MapsterRegister.cs | 17 + NetinaShop.Domain/NetinaShop.Domain.csproj | 8 +- .../CreateCategoryCommandHandler.cs | 28 + .../DeleteCategoryCommandHandler.cs | 24 + .../Categories/GetCategoriesQueryHandler.cs | 22 + .../Categories/GetCategoryQueryHandler.cs | 24 + .../UpdateCategoryCommandHandler.cs | 44 ++ .../Discounts/CreateDiscountCommandHandler.cs | 47 ++ .../Discounts/DeleteDiscountCommandHandler.cs | 22 + .../Discounts/GetDiscountQueryHandler.cs | 22 + .../Discounts/GetDiscountsQueryHandler.cs | 19 + .../Discounts/UpdateDiscountCommandHandler.cs | 52 ++ .../Products/CreateProductCommandHandler.cs | 36 + .../Products/DeleteProductCommandHandler.cs | 24 + .../Products/GetProductQueryHandler.cs | 21 + .../Products/GetProductsQueryHandler.cs | 19 + .../Products/UpdateProductCommandHandler.cs | 74 ++ .../CreateShippingCommandHandler.cs | 22 + .../DeleteShippingCommandHandler.cs | 24 + .../UpdateShippingCommandHandler.cs | 27 + .../NetinaShop.Repository.csproj | 15 +- .../Repositories/Base/BaseRepository.cs | 20 +- .../Entity/Abstracts/IDiscountRepository.cs | 5 + .../Entity/Abstracts/IProductRepository.cs | 6 + .../Repositories/Entity/DiscountRepository.cs | 12 + .../Repositories/Entity/ProductRepository.cs | 11 + 101 files changed, 4635 insertions(+), 73 deletions(-) create mode 100644 NetinaShop.Api/Controller/BlogCategoryController.cs create mode 100644 NetinaShop.Api/Controller/BrandController.cs create mode 100644 NetinaShop.Api/Controller/DiscountController.cs create mode 100644 NetinaShop.Api/Controller/ProductCategoryController.cs create mode 100644 NetinaShop.Api/Controller/ProductController.cs create mode 100644 NetinaShop.Api/Controller/ShippingController.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/CategoryCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/CategoryQueries.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/DiscountQueries.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/ProductQueries.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/BlogCategoryLDto.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/BlogLDto.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/CategoryLDto.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/BlogCategorySDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/CategorySDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/ReviewSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/SpecificationSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs create mode 100644 NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs create mode 100644 NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs create mode 100644 NetinaShop.Domain/Entities/Categories/Category.Aggregate.cs create mode 100644 NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs create mode 100644 NetinaShop.Domain/Entities/Products/Product.Aggregate.cs create mode 100644 NetinaShop.Domain/Entities/StorageFiles/StorageFile.Aggregate.cs create mode 100644 NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs create mode 100644 NetinaShop.Domain/Mappers/BlogCategoryMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/BlogMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/BlogStorageFileMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/BrandMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/BrandStorageFileMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/CategoryDiscountMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/CategoryMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/CategoryStorageFileMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/DiscountMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/ProductDiscountMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/ProductMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/ProductStorageFileMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/ReviewMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/ShippingMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/SpecificationMapper.g.cs create mode 100644 NetinaShop.Domain/Mappers/StorageFileMapper.g.cs delete mode 100644 NetinaShop.Domain/MappingRegister.cs create mode 100644 NetinaShop.Domain/MapsterRegister.cs create mode 100644 NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs create mode 100644 NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs create mode 100644 NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs create mode 100644 NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs create mode 100644 NetinaShop.Repository/Repositories/Entity/ProductRepository.cs diff --git a/NetinaShop.Api/Controller/BlogCategoryController.cs b/NetinaShop.Api/Controller/BlogCategoryController.cs new file mode 100644 index 0000000..e788200 --- /dev/null +++ b/NetinaShop.Api/Controller/BlogCategoryController.cs @@ -0,0 +1,80 @@ +using NetinaShop.Domain.Entities.Blogs; + +namespace NetinaShop.Api.Controller; + +public class BlogCategoryController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("BlogCategory") + .MapGroup($"api/blog/category") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllCategories") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetBlogCategory") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id}", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10) + .Select(BlogCategoryMapper.ProjectToSDto) + .ToListAsync(cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .Where(b => b.Id == id) + .Select(BlogCategoryMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken)); + + // POST:Create Entity + public async Task Post([FromBody] BlogCategorySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = BlogCategory.Create(dto.Name,dto.Description); + repositoryWrapper.SetRepository().Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // PUT:Update Entity + public async Task Put([FromBody] BlogCategorySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(b => b.Id == dto.Id, cancellationToken); + if (ent == null) + throw new AppException("Blog not found"); + var newEnt = BlogCategory.Create(dto.Name, dto.Description); + newEnt.Id = ent.Id; + repositoryWrapper.SetRepository().Update(newEnt); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // DELETE:Delete Entity + public async Task Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(b => b.Id == id, cancellationToken); + if (ent == null) + throw new AppException("Blog not found"); + repositoryWrapper.SetRepository().Delete(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/BlogController.cs b/NetinaShop.Api/Controller/BlogController.cs index cc97f8b..6ab01b8 100644 --- a/NetinaShop.Api/Controller/BlogController.cs +++ b/NetinaShop.Api/Controller/BlogController.cs @@ -1,6 +1,4 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; -using NetinaShop.Domain.Entities.Blogs; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using NetinaShop.Domain.Entities.Blogs; namespace NetinaShop.Api.Controller; @@ -33,28 +31,41 @@ public class BlogController : ICarterModule // GET:Get All Entity public async Task GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) - => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.OrderByDescending(b=>b.CreatedAt).Skip(page*10).Take(10).ToListAsync(cancellationToken)); + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(b=>b.CreatedAt) + .Skip(page*10).Take(10) + .Select(BlogMapper.ProjectToSDto).ToListAsync(cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) - => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.Where(b=>b.Id==id).FirstOrDefaultAsync(cancellationToken)); + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .Where(b=>b.Id==id) + .Select(BlogMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken)); // POST:Create Entity - public async Task Post([FromBody] Blog ent, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + public async Task Post([FromBody] BlogLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) { + var ent = Blog.Create(dto.Title, dto.Content, dto.Tags, dto.ReadingTime, dto.Summery, dto.IsSuggested,dto.CategoryId); + foreach (var file in dto.Files) + { + ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } repositoryWrapper.SetRepository().Add(ent); await repositoryWrapper.SaveChangesAsync(cancellationToken); return TypedResults.Ok(); } // PUT:Update Entity - public async Task Put([FromBody] Blog updated, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + public async Task Put([FromBody] BlogLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) { var ent = await repositoryWrapper.SetRepository().TableNoTracking - .FirstOrDefaultAsync(b => b.Id == updated.Id, cancellationToken); + .FirstOrDefaultAsync(b => b.Id == dto.Id, cancellationToken); if (ent == null) throw new AppException("Blog not found"); - repositoryWrapper.SetRepository().Update(updated); + var newEnt = Blog.Create(dto.Title, dto.Content, dto.Tags, dto.ReadingTime, dto.Summery, dto.IsSuggested, dto.CategoryId); + newEnt.Id = ent.Id; + repositoryWrapper.SetRepository().Update(newEnt); await repositoryWrapper.SaveChangesAsync(cancellationToken); return TypedResults.Ok(); } diff --git a/NetinaShop.Api/Controller/BrandController.cs b/NetinaShop.Api/Controller/BrandController.cs new file mode 100644 index 0000000..0f40626 --- /dev/null +++ b/NetinaShop.Api/Controller/BrandController.cs @@ -0,0 +1,84 @@ +using NetinaShop.Domain.Entities.Brands; + +namespace NetinaShop.Api.Controller; + +public class BrandController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Brand") + .MapGroup($"api/brand") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllBrands") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetBlogBrand") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id}", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10) + .Select(BrandMapper.ProjectToSDto) + .ToListAsync(cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository() + .TableNoTracking.Where(b => b.Id == id) + .Select(BrandMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken)); + + // POST:Create Entity + public async Task Post([FromBody] BrandLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = Brand.Create(dto.Name, dto.Description, dto.HasSpecialPage, dto.PageUrl); + foreach (var file in dto.Files) + { + ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } + repositoryWrapper.SetRepository().Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // PUT:Update Entity + public async Task Put([FromBody] BrandLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(b => b.Id == dto.Id, cancellationToken); + if (ent == null) + throw new AppException("Brand not found"); + var newEnt = Brand.Create(dto.Name, dto.Description, dto.HasSpecialPage, dto.PageUrl); + newEnt.Id = ent.Id; + repositoryWrapper.SetRepository().Update(newEnt); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } + + // DELETE:Delete Entity + public async Task Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(b => b.Id == id, cancellationToken); + if (ent == null) + throw new AppException("Brand not found"); + repositoryWrapper.SetRepository().Delete(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/DiscountController.cs b/NetinaShop.Api/Controller/DiscountController.cs new file mode 100644 index 0000000..8d11ce0 --- /dev/null +++ b/NetinaShop.Api/Controller/DiscountController.cs @@ -0,0 +1,54 @@ +using MediatR; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace NetinaShop.Api.Controller; + +public class DiscountController : ICarterModule +{ + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Discount") + .MapGroup($"api/discount") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllDiscounts") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetDiscount") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id}", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetDiscountsQuery(page), cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetDiscountQuery(id), cancellationToken)); + + // POST:Create Entity + public async Task Post([FromBody] CreateDiscountCommand request, IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateDiscountCommand request, IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // DELETE:Delete Entity + public async Task Delete(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteDiscountCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/ProductCategoryController.cs b/NetinaShop.Api/Controller/ProductCategoryController.cs new file mode 100644 index 0000000..aafc433 --- /dev/null +++ b/NetinaShop.Api/Controller/ProductCategoryController.cs @@ -0,0 +1,49 @@ +namespace NetinaShop.Api.Controller; + +public class ProductCategoryController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("ProductCategory") + .MapGroup($"api/product/category") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllCategories") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetCategory") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id}", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetCategoriesQuery(page),cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetCategoryQuery(id),cancellationToken)); + + // POST:Create Entity + public async Task Post([FromBody] CreateCategoryCommand request, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateCategoryCommand request, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // DELETE:Delete Entity + public async Task Delete(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteCategoryCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/ProductController.cs b/NetinaShop.Api/Controller/ProductController.cs new file mode 100644 index 0000000..1fe53b8 --- /dev/null +++ b/NetinaShop.Api/Controller/ProductController.cs @@ -0,0 +1,53 @@ +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Api.Controller; + +public class ProductController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Product") + .MapGroup($"api/product") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllProducts") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetProducts") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id}", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetProductsQuery(page),cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IMediator mediator,CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetProductQuery(id),cancellationToken)); + + // POST:Create Entity + public async Task Post([FromBody] CreateProductCommand request, IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateProductCommand request, IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // DELETE:Delete Entity + public async Task Delete(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteProductCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/ShippingController.cs b/NetinaShop.Api/Controller/ShippingController.cs new file mode 100644 index 0000000..bd7395c --- /dev/null +++ b/NetinaShop.Api/Controller/ShippingController.cs @@ -0,0 +1,51 @@ +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Api.Controller; + +public class ShippingController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Warehouse") + .MapGroup($"api/warehouse/shipping") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllShipping") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetShipping") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("{id}", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10).ToListAsync(cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.Where(b => b.Id == id).FirstOrDefaultAsync(cancellationToken)); + + // POST:Create Entity + public async Task Post([FromBody] CreateShippingCommand request, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateShippingCommand request, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + // DELETE:Delete Entity + public async Task Delete(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteShippingCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/NetinaShop.Api/NetinaShop.Api.csproj b/NetinaShop.Api/NetinaShop.Api.csproj index 975f531..21a7bd5 100644 --- a/NetinaShop.Api/NetinaShop.Api.csproj +++ b/NetinaShop.Api/NetinaShop.Api.csproj @@ -75,8 +75,15 @@ + + + + + + + diff --git a/NetinaShop.Common/NetinaShop.Common.csproj b/NetinaShop.Common/NetinaShop.Common.csproj index eec09c7..834cf1e 100644 --- a/NetinaShop.Common/NetinaShop.Common.csproj +++ b/NetinaShop.Common/NetinaShop.Common.csproj @@ -18,7 +18,6 @@ net5.0 10 enable - enable diff --git a/NetinaShop.Domain/CommandQueries/Commands/CategoryCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/CategoryCommands.cs new file mode 100644 index 0000000..a896185 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/CategoryCommands.cs @@ -0,0 +1,16 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreateCategoryCommand( + string Name, + string Description, + Guid ParentId, + List Files) : IRequest; + +public sealed record UpdateCategoryCommand( + Guid Id, + string Name, + string Description, + Guid ParentId, + List Files) : IRequest; + +public sealed record DeleteCategoryCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs new file mode 100644 index 0000000..fa5fb5f --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs @@ -0,0 +1,42 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreateDiscountCommand(string Code, +int DiscountPercent, +long DiscountAmount, +bool HasCode, +DiscountAmountType AmountType, +DiscountType Type, +int Count, +DateTime StartDate, +DateTime ExpireDate, +long PriceFloor, +bool HasPriceFloor, +long PriceCeiling, +bool HasPriceCeiling, +bool IsInfinity, +long UseCount, +bool IsForInvitation, +Guid ProductId, +Guid CategoryId) : IRequest; + +public sealed record UpdateDiscountCommand(Guid Id, + string Code, + int DiscountPercent, + long DiscountAmount, + bool HasCode, + DiscountAmountType AmountType, + DiscountType Type, + int Count, + DateTime StartDate, + DateTime ExpireDate, + long PriceFloor, + bool HasPriceFloor, + long PriceCeiling, + bool HasPriceCeiling, + bool IsInfinity, + long UseCount, + bool IsForInvitation, + Guid ProductId, + Guid CategoryId) : IRequest; + +public sealed record DeleteDiscountCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs new file mode 100644 index 0000000..3caf7d8 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs @@ -0,0 +1,29 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreateProductCommand( +string PersianName, +string EnglishName, +string Summery, +string ExpertCheck, +string Tags, +string Warranty, +Guid BrandId, +string BrandNames , +List Categories, +List Specifications, +List Files):IRequest; + +public sealed record UpdateProductCommand( + Guid Id, + string PersianName, + string EnglishName, + string Summery, + string ExpertCheck, + string Tags, + string Warranty, + Guid BrandId, + string BrandNames, + List Categories, + List Specifications, + List Files) : IRequest; +public sealed record DeleteProductCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs new file mode 100644 index 0000000..8e53e78 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs @@ -0,0 +1,19 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreateShippingCommand ( + string Title, + string WarehouseName, + bool IsFastShipping , + bool IsShipBySeller , + bool IsOriginalWarehouse) : IRequest; + +public sealed record UpdateShippingCommand( + Guid Id, + string Title, + string WarehouseName, + bool IsFastShipping, + bool IsShipBySeller, + bool IsOriginalWarehouse) : IRequest; + +public sealed record DeleteShippingCommand( + Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/CategoryQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/CategoryQueries.cs new file mode 100644 index 0000000..62bde64 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/CategoryQueries.cs @@ -0,0 +1,4 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public record GetCategoryQuery(Guid Id) : IRequest; +public record GetCategoriesQuery(int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/DiscountQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/DiscountQueries.cs new file mode 100644 index 0000000..7dae503 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/DiscountQueries.cs @@ -0,0 +1,4 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public sealed record GetDiscountQuery(Guid Id) : IRequest; +public sealed record GetDiscountsQuery(int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/ProductQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/ProductQueries.cs new file mode 100644 index 0000000..efe05ba --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/ProductQueries.cs @@ -0,0 +1,5 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + + +public sealed record GetProductQuery(Guid Id) : IRequest; +public sealed record GetProductsQuery(int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/BlogCategoryLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/BlogCategoryLDto.cs new file mode 100644 index 0000000..2f3f812 --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/BlogCategoryLDto.cs @@ -0,0 +1,8 @@ +namespace NetinaShop.Domain.Dtos.LargDtos; + +public class BlogCategoryLDto : BaseDto +{ + public string Name { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public List Blogs { get; set; } = new(); +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/BlogLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/BlogLDto.cs new file mode 100644 index 0000000..e0f9218 --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/BlogLDto.cs @@ -0,0 +1,14 @@ +namespace NetinaShop.Domain.Dtos.LargDtos; + +public class BlogLDto : BaseDto +{ + public string Title { get; internal set; } = string.Empty; + public string Content { get; internal set; } = string.Empty; + public string Tags { get; internal set; } = string.Empty; + public int ReadingTime { get; internal set; } + public string Summery { get; internal set; } = string.Empty; + public bool IsSuggested { get; internal set; } + public Guid CategoryId { get; internal set; } + public string CategoryName { get; set; } = string.Empty; + public List Files { get; internal set; } = new(); +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs new file mode 100644 index 0000000..18829be --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs @@ -0,0 +1,13 @@ +using NetinaShop.Domain.Entities.Brands; + +namespace NetinaShop.Domain.Dtos.LargDtos; + +public class BrandLDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public bool HasSpecialPage { get; set; } + public string PageUrl { get; set; } = string.Empty; + public string HeaderFileName { get; set; } = string.Empty; + public List Files { get; internal set; } = new(); +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/CategoryLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/CategoryLDto.cs new file mode 100644 index 0000000..6f6ecce --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/CategoryLDto.cs @@ -0,0 +1,10 @@ +namespace NetinaShop.Domain.Dtos.LargDtos; + +public class CategoryLDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid ParentId { get; set; } + public List Children { get; set; } = new(); + public List Files { get; internal set; } = new(); +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs new file mode 100644 index 0000000..63a25d8 --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs @@ -0,0 +1,23 @@ +namespace NetinaShop.Domain.Dtos.LargDtos; + +public class DiscountLDto : BaseDto +{ + public string Code { get; set; } = string.Empty; + public int DiscountPercent { get; set; } + public long DiscountAmount { get; set; } + public bool HasCode { get; set; } + public DiscountAmountType AmountType { get; set; } + public DiscountType Type { get; set; } + public int Count { get; set; } + public DateTime StartDate { get; set; } + public DateTime ExpireDate { get; set; } + public long PriceFloor { get; set; } + public bool HasPriceFloor { get; set; } + public long PriceCeiling { get; set; } + public bool HasPriceCeiling { get; set; } + public bool IsInfinity { get; set; } + public long UseCount { get; set; } + public bool IsForInvitation { get; set; } + public Guid ProductId { get; set; } + public Guid CategoryId { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs new file mode 100644 index 0000000..f66c436 --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs @@ -0,0 +1,18 @@ +namespace NetinaShop.Domain.Dtos.LargDtos; + +public class ProductLDto : BaseDto +{ + public string PersianName { get; set; } = string.Empty; + public string EnglishName { get; set; } = string.Empty; + public string Summery { get; set; } = string.Empty; + public string ExpertCheck { get; set; } = string.Empty; + public string Tags { get; set; } = string.Empty; + public string Warranty { get; set; } = string.Empty; + public Guid BrandId { get; set; } + public string BrandNames { get; set; } = string.Empty; + + public List Specifications { get; set; } = new(); + public List Reviews { get; set; } = new(); + public List Categories { get; set; } = new(); + public List Files { get; set; } = new(); +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BlogCategorySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BlogCategorySDto.cs new file mode 100644 index 0000000..dbfb5f4 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/BlogCategorySDto.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class BlogCategorySDto : BaseDto +{ + public string Name { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs new file mode 100644 index 0000000..83e63bf --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs @@ -0,0 +1,16 @@ +using NetinaShop.Domain.Entities.Blogs; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class BlogSDto : BaseDto +{ + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public string Tags { get; set; } = string.Empty; + public int ReadingTime { get; set; } + public string Summery { get; set; } = string.Empty; + public bool IsSuggested { get; set; } + public Guid CategoryId { get; set; } + public string CategoryName { get; set; } = string.Empty; + public string HeaderFileName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs new file mode 100644 index 0000000..1fa0af1 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs @@ -0,0 +1,12 @@ +using NetinaShop.Domain.Entities.Brands; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class BrandSDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public bool HasSpecialPage { get; set; } + public string PageUrl { get; set; } = string.Empty; + public string HeaderFileName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/CategorySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/CategorySDto.cs new file mode 100644 index 0000000..c1cc7a3 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/CategorySDto.cs @@ -0,0 +1,8 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class CategorySDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid ParentId { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs new file mode 100644 index 0000000..18df5ca --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs @@ -0,0 +1,23 @@ +using NetinaShop.Domain.Entities.Discounts; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class DiscountSDto : BaseDto +{ + public string Code { get; set; } = string.Empty; + public int DiscountPercent { get; set; } + public long DiscountAmount { get; set; } + public bool HasCode { get; set; } + public DiscountAmountType AmountType { get; set; } + public DiscountType Type { get; set; } + public int Count { get; set; } + public DateTime StartDate { get; set; } + public DateTime ExpireDate { get; set; } + public long PriceFloor { get; set; } + public bool HasPriceFloor { get; set; } + public long PriceCeiling { get; set; } + public bool HasPriceCeiling { get; set; } + public bool IsInfinity { get; set; } + public long UseCount { get; set; } + public bool IsForInvitation { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs new file mode 100644 index 0000000..3642468 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs @@ -0,0 +1,9 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class ProductCategorySDto : BaseDto +{ + + public Guid CategoryId { get; set; } + public string CategoryName { get; set; } = string.Empty; + public Guid ProductId { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs new file mode 100644 index 0000000..4e78a16 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs @@ -0,0 +1,14 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class ProductSDto : BaseDto +{ + + public string PersianName { get; set; } = string.Empty; + public string EnglishName { get; set; } = string.Empty; + public string Summery { get; set; } = string.Empty; + public string ExpertCheck { get; set; } = string.Empty; + public string Tags { get; set; } = string.Empty; + public string Warranty { get; set; } = string.Empty; + public Guid BrandId { get; set; } + public string BrandNames { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ReviewSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ReviewSDto.cs new file mode 100644 index 0000000..774bc51 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/ReviewSDto.cs @@ -0,0 +1,11 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class ReviewSDto : BaseDto +{ + public string Title { get; set; } = string.Empty; + public string Comment { get; set; } = string.Empty; + public float Rate { get; set; } + public bool IsBuyer { get; set; } + public Guid ProductId { get; set; } + public Guid UserId { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs new file mode 100644 index 0000000..3d34620 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs @@ -0,0 +1,8 @@ +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class ShippingSDto : BaseDto +{ + +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/SpecificationSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/SpecificationSDto.cs new file mode 100644 index 0000000..a43403e --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/SpecificationSDto.cs @@ -0,0 +1,12 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class SpecificationSDto : BaseDto +{ + + public string Title { get; set; } = string.Empty; + public string Detail { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; + public bool IsFeature { get; set; } + public Guid ProductId { get; set; } + public Guid ParentId { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs new file mode 100644 index 0000000..5e856f7 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs @@ -0,0 +1,13 @@ +using NetinaShop.Domain.Entities.StorageFiles; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class StorageFileSDto : BaseDto +{ + public string Name { get; internal set; } = string.Empty; + public string FileLocation { get; internal set; } = string.Empty; + public string FileName { get; internal set; } = string.Empty; + public bool IsHeader { get; internal set; } + public bool IsPrimary { get; internal set; } + public StorageFileType FileType { get; internal set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs b/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs new file mode 100644 index 0000000..0338968 --- /dev/null +++ b/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs @@ -0,0 +1,34 @@ +using NetinaShop.Domain.Entities.StorageFiles; + +namespace NetinaShop.Domain.Entities.Blogs; + +public partial class Blog +{ + public static Blog Create(string title, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId) + { + return new Blog(title, content, tags, readingTime, summery, isSuggested, categoryId); + } + + public BlogStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + var file = BlogStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, this.Id); + Files.Add(file); + return file; + } +} + +public partial class BlogStorageFile +{ + public static BlogStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid blogId) + { + return new BlogStorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType, blogId); + } +} + +public partial class BlogCategory +{ + public static BlogCategory Create(string name,string description) + { + return new BlogCategory(name, description); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Blogs/Blog.cs b/NetinaShop.Domain/Entities/Blogs/Blog.cs index 23aa769..4d7b5ec 100644 --- a/NetinaShop.Domain/Entities/Blogs/Blog.cs +++ b/NetinaShop.Domain/Entities/Blogs/Blog.cs @@ -1,7 +1,26 @@ namespace NetinaShop.Domain.Entities.Blogs; -public class Blog : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] + +public partial class Blog : ApiEntity { + public Blog() + { + + } + public Blog(string title,string content,string tags, int readingTime,string summery, bool isSuggested, Guid categoryId) + { + Title = title; + Content = content; + Tags = tags; + ReadingTime = readingTime; + Summery = summery; + IsSuggested = isSuggested; + CategoryId = categoryId; + } public string Title { get; internal set; } = string.Empty; public string Content { get; internal set; } = string.Empty; public string Tags { get; internal set; } = string.Empty; diff --git a/NetinaShop.Domain/Entities/Blogs/BlogCategory.cs b/NetinaShop.Domain/Entities/Blogs/BlogCategory.cs index 47ca3e7..5bcb316 100644 --- a/NetinaShop.Domain/Entities/Blogs/BlogCategory.cs +++ b/NetinaShop.Domain/Entities/Blogs/BlogCategory.cs @@ -1,7 +1,20 @@ namespace NetinaShop.Domain.Entities.Blogs; - -public class BlogCategory : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class BlogCategory : ApiEntity { + public BlogCategory() + { + + } + + public BlogCategory(string name, string description) + { + Name = name; + Description = description; + } public string Name { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty; public List Blogs { get; internal set; } = new(); diff --git a/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs b/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs index 9e19bf8..b6bf22f 100644 --- a/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs +++ b/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs @@ -2,8 +2,17 @@ namespace NetinaShop.Domain.Entities.Blogs; -public class BlogStorageFile : StorageFile +public partial class BlogStorageFile : StorageFile { + public BlogStorageFile() + { + + } + public BlogStorageFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid blogId) : + base(name, fileLocation, fileName, isHeader, isPrimary, fileType) + { + BlogId = blogId; + } public Guid BlogId { get; internal set; } public Blog? Blog { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs b/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs new file mode 100644 index 0000000..83ac8f3 --- /dev/null +++ b/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs @@ -0,0 +1,24 @@ +namespace NetinaShop.Domain.Entities.Brands; + +public partial class Brand +{ + public static Brand Create(string name, string description, bool hasSpecialPage, string pageUrl) + { + return new Brand( name, description, hasSpecialPage, pageUrl); + } + + public BrandStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + var file = BrandStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, this.Id); + Files.Add(file); + return file; + } +} + +public partial class BrandStorageFile +{ + public static BrandStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid brandId) + { + return new BrandStorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType, brandId); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Brands/Brand.cs b/NetinaShop.Domain/Entities/Brands/Brand.cs index 2dd37f1..638e011 100644 --- a/NetinaShop.Domain/Entities/Brands/Brand.cs +++ b/NetinaShop.Domain/Entities/Brands/Brand.cs @@ -1,9 +1,24 @@ -using NetinaShop.Domain.Entities.Products; +namespace NetinaShop.Domain.Entities.Brands; -namespace NetinaShop.Domain.Entities.Brands; +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] -public class Brand : ApiEntity +public partial class Brand : ApiEntity { + public Brand() + { + + } + + public Brand(string name, string description, bool hasSpecialPage, string pageUrl) + { + Name = name; + Description = description; + HasSpecialPage = hasSpecialPage; + PageUrl = pageUrl; + } public string Name { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty; public bool HasSpecialPage { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs b/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs index d041a13..ad78a6f 100644 --- a/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs +++ b/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs @@ -2,8 +2,18 @@ namespace NetinaShop.Domain.Entities.Brands; -public class BrandStorageFile : StorageFile +public partial class BrandStorageFile : StorageFile { + public BrandStorageFile() + { + + } + + public BrandStorageFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid brandId) : + base(name, fileLocation, fileName, isHeader, isPrimary, fileType) + { + BrandId = brandId; + } public Guid BrandId { get; internal set; } public Brand? Brand { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Categories/Category.Aggregate.cs b/NetinaShop.Domain/Entities/Categories/Category.Aggregate.cs new file mode 100644 index 0000000..6846433 --- /dev/null +++ b/NetinaShop.Domain/Entities/Categories/Category.Aggregate.cs @@ -0,0 +1,29 @@ +namespace NetinaShop.Domain.Entities.Categories; + +public partial class Category +{ + public static Category Create(string name, string description) + { + return new Category(name, description); + } + + public void SetParent(Guid parentId) + { + ParentId = parentId; + } + + public CategoryStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + var file = CategoryStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, this.Id); + Files.Add(file); + return file; + } +} + +public partial class CategoryStorageFile +{ + public static CategoryStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid categoryId) + { + return new CategoryStorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType, categoryId); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Categories/Category.cs b/NetinaShop.Domain/Entities/Categories/Category.cs index e608ea6..ebfea65 100644 --- a/NetinaShop.Domain/Entities/Categories/Category.cs +++ b/NetinaShop.Domain/Entities/Categories/Category.cs @@ -1,9 +1,20 @@ -using NetinaShop.Domain.Entities.Products; - -namespace NetinaShop.Domain.Entities.Categories; - -public class Category : ApiEntity +namespace NetinaShop.Domain.Entities.Categories; +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class Category : ApiEntity { + public Category() + { + + } + + public Category(string name, string description) + { + Name = name; + Description = description; + } public string Name { get; internal set; } = string.Empty; public string Description { get; internal set; } = string.Empty; diff --git a/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs b/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs index 3b890cf..263ba45 100644 --- a/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs +++ b/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs @@ -2,8 +2,18 @@ namespace NetinaShop.Domain.Entities.Categories; -public class CategoryStorageFile : StorageFile +public partial class CategoryStorageFile : StorageFile { + public CategoryStorageFile() + { + + } + + public CategoryStorageFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid categoryId) : + base(name, fileLocation, fileName, isHeader, isPrimary, fileType) + { + CategoryId = categoryId; + } public Guid CategoryId { get; internal set; } public Category? Category { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs b/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs index 39ab22c..74f9122 100644 --- a/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs +++ b/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs @@ -1,7 +1,18 @@ namespace NetinaShop.Domain.Entities.Discounts; -public class CategoryDiscount : Discount +public partial class CategoryDiscount : Discount { + public CategoryDiscount() + { + + } + + public CategoryDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation, Guid categoryId) + : base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, + isForInvitation) + { + CategoryId = categoryId; + } public Guid CategoryId { get; internal set; } public Category? Category { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs b/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs new file mode 100644 index 0000000..da3bd09 --- /dev/null +++ b/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs @@ -0,0 +1,31 @@ +namespace NetinaShop.Domain.Entities.Discounts; + +public partial class Discount +{ + public static Discount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation) + { + return new Discount(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, + expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, + isForInvitation); + } +} + +public partial class ProductDiscount +{ + public static ProductDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation , Guid productId) + { + return new ProductDiscount(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, + expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, + isForInvitation, productId); + } +} + +public partial class CategoryDiscount +{ + public static CategoryDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation, Guid categoryId) + { + return new CategoryDiscount(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, + expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, + isForInvitation, categoryId); + } +} diff --git a/NetinaShop.Domain/Entities/Discounts/Discount.cs b/NetinaShop.Domain/Entities/Discounts/Discount.cs index db83eda..51a2b75 100644 --- a/NetinaShop.Domain/Entities/Discounts/Discount.cs +++ b/NetinaShop.Domain/Entities/Discounts/Discount.cs @@ -1,7 +1,36 @@ namespace NetinaShop.Domain.Entities.Discounts; -public class Discount : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] + +public partial class Discount : ApiEntity { + public Discount() + { + + } + + public Discount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation) + { + Code = code; + DiscountPercent = discountPercent; + DiscountAmount = discountAmount; + HasCode = hasCode; + AmountType = amountType; + Type = type; + Count = count; + StartDate = startDate; + ExpireDate = expireDate; + PriceFloor = priceFloor; + HasPriceFloor = hasPriceFloor; + PriceCeiling = priceCeiling; + HasPriceCeiling = hasPriceCeiling; + IsInfinity = isInfinity; + UseCount = useCount; + IsForInvitation = isForInvitation; + } public string Code { get; internal set; } = string.Empty; public int DiscountPercent { get; internal set; } public long DiscountAmount { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs b/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs index e679e34..b129d7f 100644 --- a/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs +++ b/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs @@ -1,7 +1,18 @@ namespace NetinaShop.Domain.Entities.Discounts; -public class ProductDiscount : Discount +public partial class ProductDiscount : Discount { + public ProductDiscount() + { + + } + + public ProductDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,Guid productId) + : base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, isForInvitation) + { + ProductId = productId; + } + public Guid ProductId { get; internal set; } public Product? Product { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs b/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs new file mode 100644 index 0000000..da8730a --- /dev/null +++ b/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs @@ -0,0 +1,64 @@ +namespace NetinaShop.Domain.Entities.Products; + +public partial class Product +{ + public static Product Create(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, Guid brandId) + { + return new Product(persianName, englishName, summery, expertCheck, tags, warranty, brandId); + } + + public ProductCategory AddCategory(Guid categoryId) + { + var ent = ProductCategory.Create(categoryId, Id); + Categories.Add(ent); + return ent; + } + + public ProductStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + var ent = ProductStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, Id); + Files.Add(ent); + return ent; + } + + public Specification AddSpecification(string title, string detail,string value, bool isFeature, Guid parentId) + { + var ent = Specification.Create(title, detail, value, isFeature, Id, parentId); + Specifications.Add(ent); + return ent; + } +} + +public partial class ProductCategory +{ + public static ProductCategory Create(Guid categoryId, Guid productId) + { + return new ProductCategory(categoryId, productId); + } +} + +public partial class ProductStorageFile +{ + public static ProductStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, + bool isPrimary, StorageFileType fileType, Guid productId) + { + return new ProductStorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType, productId); + } +} + +public partial class Review +{ + public static Review Create(string title, string comment, float rate, bool isBuyer, Guid productId, Guid userId) + { + return new Review(title, comment, rate, isBuyer, productId, userId); + } + +} + +public partial class Specification +{ + public static Specification Create(string title,string value, string detail, bool isFeature, Guid productId, Guid parentId) + { + return new Specification(title, detail, value, isFeature, productId, parentId); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Products/Product.cs b/NetinaShop.Domain/Entities/Products/Product.cs index c3c5678..feb966d 100644 --- a/NetinaShop.Domain/Entities/Products/Product.cs +++ b/NetinaShop.Domain/Entities/Products/Product.cs @@ -1,10 +1,25 @@ -using NetinaShop.Domain.Entities.Brands; -using NetinaShop.Domain.Entities.Orders; - -namespace NetinaShop.Domain.Entities.Products; - -public class Product : ApiEntity +namespace NetinaShop.Domain.Entities.Products; +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class Product : ApiEntity { + public Product() + { + + } + + public Product(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, Guid brandId) + { + PersianName = persianName; + EnglishName = englishName; + Summery = summery; + ExpertCheck = expertCheck; + Tags = tags; + Warranty = warranty; + BrandId = brandId; + } public string PersianName { get; internal set; } = string.Empty; public string EnglishName { get; internal set; } = string.Empty; public string Summery { get; internal set; } = string.Empty; diff --git a/NetinaShop.Domain/Entities/Products/ProductCategory.cs b/NetinaShop.Domain/Entities/Products/ProductCategory.cs index d89b994..de7fced 100644 --- a/NetinaShop.Domain/Entities/Products/ProductCategory.cs +++ b/NetinaShop.Domain/Entities/Products/ProductCategory.cs @@ -1,9 +1,20 @@ -using NetinaShop.Domain.Entities.Categories; - -namespace NetinaShop.Domain.Entities.Products; - -public class ProductCategory : ApiEntity +namespace NetinaShop.Domain.Entities.Products; +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class ProductCategory : ApiEntity { + public ProductCategory(Guid categoryId, Guid productId) + { + CategoryId = categoryId; + ProductId = productId; + } + + public ProductCategory() + { + + } public Guid CategoryId { get; internal set; } public Category? Category { get; internal set; } public Guid ProductId { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Products/ProductStorageFile.cs b/NetinaShop.Domain/Entities/Products/ProductStorageFile.cs index d8476a7..93c8cad 100644 --- a/NetinaShop.Domain/Entities/Products/ProductStorageFile.cs +++ b/NetinaShop.Domain/Entities/Products/ProductStorageFile.cs @@ -1,9 +1,17 @@ -using NetinaShop.Domain.Entities.StorageFiles; +namespace NetinaShop.Domain.Entities.Products; -namespace NetinaShop.Domain.Entities.Products; - -public class ProductStorageFile : StorageFile +public partial class ProductStorageFile : StorageFile { + public ProductStorageFile() + { + + } + + public ProductStorageFile( string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid productId) + : base(name, fileLocation, fileName, isHeader, isPrimary, fileType) + { + ProductId = productId; + } public Guid ProductId { get; internal set; } public Product? Product { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Products/Review.cs b/NetinaShop.Domain/Entities/Products/Review.cs index caf8cb4..f22d10d 100644 --- a/NetinaShop.Domain/Entities/Products/Review.cs +++ b/NetinaShop.Domain/Entities/Products/Review.cs @@ -1,9 +1,24 @@ -using NetinaShop.Domain.Entities.Users; - -namespace NetinaShop.Domain.Entities.Products; - -public class Review : ApiEntity +namespace NetinaShop.Domain.Entities.Products; +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class Review : ApiEntity { + public Review() + { + + } + + public Review(string title, string comment, float rate, bool isBuyer, Guid productId, Guid userId) + { + Title = title; + Comment = comment; + Rate = rate; + IsBuyer = isBuyer; + ProductId = productId; + UserId = userId; + } public string Title { get; internal set; } = string.Empty; public string Comment { get; internal set; } = string.Empty; public float Rate { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Products/Specification.cs b/NetinaShop.Domain/Entities/Products/Specification.cs index 0bc8881..6e1befa 100644 --- a/NetinaShop.Domain/Entities/Products/Specification.cs +++ b/NetinaShop.Domain/Entities/Products/Specification.cs @@ -1,9 +1,27 @@ namespace NetinaShop.Domain.Entities.Products; - -public class Specification : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class Specification : ApiEntity { + public Specification() + { + + } + + public Specification(string title, string detail,string value, bool isFeature, Guid productId, Guid parentId) + { + Title = title; + Detail = detail; + Value = value; + IsFeature = isFeature; + ProductId = productId; + ParentId = parentId; + } public string Title { get; internal set; } = string.Empty; public string Detail { get; internal set; } = string.Empty; + public string Value { get; internal set; } = string.Empty; public bool IsFeature { get; internal set; } public Guid ProductId { get; internal set; } diff --git a/NetinaShop.Domain/Entities/StorageFiles/StorageFile.Aggregate.cs b/NetinaShop.Domain/Entities/StorageFiles/StorageFile.Aggregate.cs new file mode 100644 index 0000000..1b56497 --- /dev/null +++ b/NetinaShop.Domain/Entities/StorageFiles/StorageFile.Aggregate.cs @@ -0,0 +1,9 @@ +namespace NetinaShop.Domain.Entities.StorageFiles; + +public partial class StorageFile +{ + public static StorageFile Create(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + return new StorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/StorageFiles/StorageFile.cs b/NetinaShop.Domain/Entities/StorageFiles/StorageFile.cs index 0f29568..f40b236 100644 --- a/NetinaShop.Domain/Entities/StorageFiles/StorageFile.cs +++ b/NetinaShop.Domain/Entities/StorageFiles/StorageFile.cs @@ -1,7 +1,23 @@ namespace NetinaShop.Domain.Entities.StorageFiles; - -public class StorageFile : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class StorageFile : ApiEntity { + public StorageFile() + { + + } + public StorageFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) + { + Name = name; + FileLocation = fileLocation; + FileName = fileName; + IsHeader = isHeader; + IsPrimary = isPrimary; + FileType = fileType; + } public string Name { get; internal set; } = string.Empty; public string FileLocation { get; internal set; } = string.Empty; public string FileName { get; internal set; } = string.Empty; diff --git a/NetinaShop.Domain/Entities/Warehouses/Shipping.cs b/NetinaShop.Domain/Entities/Warehouses/Shipping.cs index 3c15f39..84036ef 100644 --- a/NetinaShop.Domain/Entities/Warehouses/Shipping.cs +++ b/NetinaShop.Domain/Entities/Warehouses/Shipping.cs @@ -1,7 +1,24 @@ namespace NetinaShop.Domain.Entities.Warehouses; - -public class Shipping : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] +public partial class Shipping : ApiEntity { + public Shipping() + { + + } + + public Shipping(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse) + { + Title = title; + WarehouseName = warehouseName; + IsFastShipping = isFastShipping; + IsShipBySeller = isShipBySeller; + IsOriginalWarehouse = isOriginalWarehouse; + } + public string Title { get; internal set; } = string.Empty; public string WarehouseName { get; internal set; } = string.Empty; public bool IsFastShipping { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs b/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs new file mode 100644 index 0000000..ca20152 --- /dev/null +++ b/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs @@ -0,0 +1,14 @@ +namespace NetinaShop.Domain.Entities.Warehouses; + +public partial class Warehouses +{ + +} + +public partial class Shipping +{ + public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse) + { + return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/BlogCategoryMapper.g.cs b/NetinaShop.Domain/Mappers/BlogCategoryMapper.g.cs new file mode 100644 index 0000000..783373c --- /dev/null +++ b/NetinaShop.Domain/Mappers/BlogCategoryMapper.g.cs @@ -0,0 +1,305 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Blogs; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class BlogCategoryMapper + { + public static BlogCategory AdaptToBlogCategory(this BlogCategoryLDto p1) + { + return p1 == null ? null : new BlogCategory() + { + Name = p1.Name, + Description = p1.Description, + Blogs = funcMain1(p1.Blogs), + Id = p1.Id + }; + } + public static BlogCategory AdaptTo(this BlogCategoryLDto p3, BlogCategory p4) + { + if (p3 == null) + { + return null; + } + BlogCategory result = p4 ?? new BlogCategory(); + + result.Name = p3.Name; + result.Description = p3.Description; + result.Blogs = funcMain2(p3.Blogs, result.Blogs); + result.Id = p3.Id; + return result; + + } + public static Expression> ProjectToBlogCategory => p7 => new BlogCategory() + { + Name = p7.Name, + Description = p7.Description, + Blogs = p7.Blogs.Select(p8 => new Blog() + { + Title = p8.Title, + Content = p8.Content, + Tags = p8.Tags, + ReadingTime = p8.ReadingTime, + Summery = p8.Summery, + IsSuggested = p8.IsSuggested, + CategoryId = p8.CategoryId, + Category = new BlogCategory() + { + Name = p8.CategoryName, + Id = p8.CategoryId + }, + Id = p8.Id + }).ToList(), + Id = p7.Id + }; + public static BlogCategoryLDto AdaptToLDto(this BlogCategory p9) + { + return p9 == null ? null : new BlogCategoryLDto() + { + Name = p9.Name, + Description = p9.Description, + Blogs = funcMain3(p9.Blogs), + Id = p9.Id + }; + } + public static BlogCategoryLDto AdaptTo(this BlogCategory p11, BlogCategoryLDto p12) + { + if (p11 == null) + { + return null; + } + BlogCategoryLDto result = p12 ?? new BlogCategoryLDto(); + + result.Name = p11.Name; + result.Description = p11.Description; + result.Blogs = funcMain6(p11.Blogs, result.Blogs); + result.Id = p11.Id; + return result; + + } + public static Expression> ProjectToLDto => p15 => new BlogCategoryLDto() + { + Name = p15.Name, + Description = p15.Description, + Blogs = p15.Blogs.Select(p16 => new BlogSDto() + { + Title = p16.Title, + Content = p16.Content, + Tags = p16.Tags, + ReadingTime = p16.ReadingTime, + Summery = p16.Summery, + IsSuggested = p16.IsSuggested, + CategoryId = p16.CategoryId, + CategoryName = p16.Category.Name, + HeaderFileName = p16.Files.Count > 0 && p16.Files.Any(f => f.IsHeader) ? p16.Files.FirstOrDefault(f => f.IsHeader).FileName : string.Empty, + Id = p16.Id + }).ToList(), + Id = p15.Id + }; + public static BlogCategory AdaptToBlogCategory(this BlogCategorySDto p17) + { + return p17 == null ? null : new BlogCategory() + { + Name = p17.Name, + Description = p17.Description, + Id = p17.Id + }; + } + public static BlogCategory AdaptTo(this BlogCategorySDto p18, BlogCategory p19) + { + if (p18 == null) + { + return null; + } + BlogCategory result = p19 ?? new BlogCategory(); + + result.Name = p18.Name; + result.Description = p18.Description; + result.Id = p18.Id; + return result; + + } + public static BlogCategorySDto AdaptToSDto(this BlogCategory p20) + { + return p20 == null ? null : new BlogCategorySDto() + { + Name = p20.Name, + Description = p20.Description, + Id = p20.Id + }; + } + public static BlogCategorySDto AdaptTo(this BlogCategory p21, BlogCategorySDto p22) + { + if (p21 == null) + { + return null; + } + BlogCategorySDto result = p22 ?? new BlogCategorySDto(); + + result.Name = p21.Name; + result.Description = p21.Description; + result.Id = p21.Id; + return result; + + } + public static Expression> ProjectToSDto => p23 => new BlogCategorySDto() + { + Name = p23.Name, + Description = p23.Description, + Id = p23.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + BlogSDto item = p2[i]; + result.Add(item == null ? null : new Blog() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + Category = new BlogCategory() + { + Name = item.CategoryName, + Id = item.CategoryId + }, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + BlogSDto item = p5[i]; + result.Add(item == null ? null : new Blog() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + Category = new BlogCategory() + { + Name = item.CategoryName, + Id = item.CategoryId + }, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + Blog item = p10[i]; + result.Add(item == null ? null : new BlogSDto() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + CategoryName = item.Category == null ? null : item.Category.Name, + HeaderFileName = item.Files.Count > 0 && item.Files.Any(funcMain4) ? item.Files.FirstOrDefault(funcMain5).FileName : string.Empty, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain6(List p13, List p14) + { + if (p13 == null) + { + return null; + } + List result = new List(p13.Count); + + int i = 0; + int len = p13.Count; + + while (i < len) + { + Blog item = p13[i]; + result.Add(item == null ? null : new BlogSDto() + { + Title = item.Title, + Content = item.Content, + Tags = item.Tags, + ReadingTime = item.ReadingTime, + Summery = item.Summery, + IsSuggested = item.IsSuggested, + CategoryId = item.CategoryId, + CategoryName = item.Category == null ? null : item.Category.Name, + HeaderFileName = item.Files.Count > 0 && item.Files.Any(funcMain4) ? item.Files.FirstOrDefault(funcMain5).FileName : string.Empty, + Id = item.Id + }); + i++; + } + return result; + + } + + private static bool funcMain4(BlogStorageFile f) + { + return f.IsHeader; + } + + private static bool funcMain5(BlogStorageFile f) + { + return f.IsHeader; + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/BlogMapper.g.cs b/NetinaShop.Domain/Mappers/BlogMapper.g.cs new file mode 100644 index 0000000..5844d48 --- /dev/null +++ b/NetinaShop.Domain/Mappers/BlogMapper.g.cs @@ -0,0 +1,359 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using Mapster.Models; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Blogs; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class BlogMapper + { + public static Blog AdaptToBlog(this BlogLDto p1) + { + return p1 == null ? null : new Blog() + { + Title = p1.Title, + Content = p1.Content, + Tags = p1.Tags, + ReadingTime = p1.ReadingTime, + Summery = p1.Summery, + IsSuggested = p1.IsSuggested, + CategoryId = p1.CategoryId, + Files = funcMain1(p1.Files), + Id = p1.Id + }; + } + public static Blog AdaptTo(this BlogLDto p3, Blog p4) + { + if (p3 == null) + { + return null; + } + Blog result = p4 ?? new Blog(); + + result.Title = p3.Title; + result.Content = p3.Content; + result.Tags = p3.Tags; + result.ReadingTime = p3.ReadingTime; + result.Summery = p3.Summery; + result.IsSuggested = p3.IsSuggested; + result.CategoryId = p3.CategoryId; + result.Files = funcMain2(p3.Files, result.Files); + result.Id = p3.Id; + return result; + + } + public static Expression> ProjectToBlog => p7 => new Blog() + { + Title = p7.Title, + Content = p7.Content, + Tags = p7.Tags, + ReadingTime = p7.ReadingTime, + Summery = p7.Summery, + IsSuggested = p7.IsSuggested, + CategoryId = p7.CategoryId, + Files = p7.Files.Select(p8 => new BlogStorageFile() + { + Name = p8.Name, + FileLocation = p8.FileLocation, + FileName = p8.FileName, + IsHeader = p8.IsHeader, + IsPrimary = p8.IsPrimary, + FileType = p8.FileType, + Id = p8.Id + }).ToList(), + Id = p7.Id + }; + public static BlogLDto AdaptToLDto(this Blog p9) + { + return p9 == null ? null : new BlogLDto() + { + Title = p9.Title, + Content = p9.Content, + Tags = p9.Tags, + ReadingTime = p9.ReadingTime, + Summery = p9.Summery, + IsSuggested = p9.IsSuggested, + CategoryId = p9.CategoryId, + CategoryName = p9.Category == null ? null : p9.Category.Name, + Files = funcMain3(p9.Files), + Id = p9.Id + }; + } + public static BlogLDto AdaptTo(this Blog p11, BlogLDto p12) + { + if (p11 == null) + { + return null; + } + BlogLDto result = p12 ?? new BlogLDto(); + + result.Title = p11.Title; + result.Content = p11.Content; + result.Tags = p11.Tags; + result.ReadingTime = p11.ReadingTime; + result.Summery = p11.Summery; + result.IsSuggested = p11.IsSuggested; + result.CategoryId = p11.CategoryId; + result.CategoryName = p11.Category == null ? null : p11.Category.Name; + result.Files = funcMain4(p11.Files, result.Files); + result.Id = p11.Id; + return result; + + } + public static Expression> ProjectToLDto => p15 => new BlogLDto() + { + Title = p15.Title, + Content = p15.Content, + Tags = p15.Tags, + ReadingTime = p15.ReadingTime, + Summery = p15.Summery, + IsSuggested = p15.IsSuggested, + CategoryId = p15.CategoryId, + CategoryName = p15.Category.Name, + Files = p15.Files.Select(p16 => new StorageFileSDto() + { + Name = p16.Name, + FileLocation = p16.FileLocation, + FileName = p16.FileName, + IsHeader = p16.IsHeader, + IsPrimary = p16.IsPrimary, + FileType = p16.FileType, + Id = p16.Id + }).ToList(), + Id = p15.Id + }; + public static Blog AdaptToBlog(this BlogSDto p17) + { + return p17 == null ? null : new Blog() + { + Title = p17.Title, + Content = p17.Content, + Tags = p17.Tags, + ReadingTime = p17.ReadingTime, + Summery = p17.Summery, + IsSuggested = p17.IsSuggested, + CategoryId = p17.CategoryId, + Category = new BlogCategory() + { + Name = p17.CategoryName, + Id = p17.CategoryId + }, + Id = p17.Id + }; + } + public static Blog AdaptTo(this BlogSDto p18, Blog p19) + { + if (p18 == null) + { + return null; + } + Blog result = p19 ?? new Blog(); + + result.Title = p18.Title; + result.Content = p18.Content; + result.Tags = p18.Tags; + result.ReadingTime = p18.ReadingTime; + result.Summery = p18.Summery; + result.IsSuggested = p18.IsSuggested; + result.CategoryId = p18.CategoryId; + result.Category = funcMain5(new Never(), result.Category, p18); + result.Id = p18.Id; + return result; + + } + public static BlogSDto AdaptToSDto(this Blog p22) + { + return p22 == null ? null : new BlogSDto() + { + Title = p22.Title, + Content = p22.Content, + Tags = p22.Tags, + ReadingTime = p22.ReadingTime, + Summery = p22.Summery, + IsSuggested = p22.IsSuggested, + CategoryId = p22.CategoryId, + CategoryName = p22.Category == null ? null : p22.Category.Name, + HeaderFileName = p22.Files.Count > 0 && p22.Files.Any(funcMain6) ? p22.Files.FirstOrDefault(funcMain7).FileName : string.Empty, + Id = p22.Id + }; + } + public static BlogSDto AdaptTo(this Blog p23, BlogSDto p24) + { + if (p23 == null) + { + return null; + } + BlogSDto result = p24 ?? new BlogSDto(); + + result.Title = p23.Title; + result.Content = p23.Content; + result.Tags = p23.Tags; + result.ReadingTime = p23.ReadingTime; + result.Summery = p23.Summery; + result.IsSuggested = p23.IsSuggested; + result.CategoryId = p23.CategoryId; + result.CategoryName = p23.Category == null ? null : p23.Category.Name; + result.HeaderFileName = p23.Files.Count > 0 && p23.Files.Any(funcMain6) ? p23.Files.FirstOrDefault(funcMain7).FileName : string.Empty; + result.Id = p23.Id; + return result; + + } + public static Expression> ProjectToSDto => p25 => new BlogSDto() + { + Title = p25.Title, + Content = p25.Content, + Tags = p25.Tags, + ReadingTime = p25.ReadingTime, + Summery = p25.Summery, + IsSuggested = p25.IsSuggested, + CategoryId = p25.CategoryId, + CategoryName = p25.Category.Name, + HeaderFileName = p25.Files.Count > 0 && p25.Files.Any(f => f.IsHeader) ? p25.Files.FirstOrDefault(f => f.IsHeader).FileName : string.Empty, + Id = p25.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + StorageFileSDto item = p2[i]; + result.Add(item == null ? null : new BlogStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + StorageFileSDto item = p5[i]; + result.Add(item == null ? null : new BlogStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + BlogStorageFile item = p10[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p13, List p14) + { + if (p13 == null) + { + return null; + } + List result = new List(p13.Count); + + int i = 0; + int len = p13.Count; + + while (i < len) + { + BlogStorageFile item = p13[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static BlogCategory funcMain5(Never p20, BlogCategory p21, BlogSDto p18) + { + BlogCategory result = p21 ?? new BlogCategory(); + + result.Name = p18.CategoryName; + result.Id = p18.CategoryId; + return result; + + } + + private static bool funcMain6(BlogStorageFile f) + { + return f.IsHeader; + } + + private static bool funcMain7(BlogStorageFile f) + { + return f.IsHeader; + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/BlogStorageFileMapper.g.cs b/NetinaShop.Domain/Mappers/BlogStorageFileMapper.g.cs new file mode 100644 index 0000000..5801ccf --- /dev/null +++ b/NetinaShop.Domain/Mappers/BlogStorageFileMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class BlogStorageFileMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/BrandMapper.g.cs b/NetinaShop.Domain/Mappers/BrandMapper.g.cs new file mode 100644 index 0000000..b03a114 --- /dev/null +++ b/NetinaShop.Domain/Mappers/BrandMapper.g.cs @@ -0,0 +1,303 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Brands; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class BrandMapper + { + public static Brand AdaptToBrand(this BrandLDto p1) + { + return p1 == null ? null : new Brand() + { + Name = p1.Name, + Description = p1.Description, + HasSpecialPage = p1.HasSpecialPage, + PageUrl = p1.PageUrl, + Files = funcMain1(p1.Files), + Id = p1.Id + }; + } + public static Brand AdaptTo(this BrandLDto p3, Brand p4) + { + if (p3 == null) + { + return null; + } + Brand result = p4 ?? new Brand(); + + result.Name = p3.Name; + result.Description = p3.Description; + result.HasSpecialPage = p3.HasSpecialPage; + result.PageUrl = p3.PageUrl; + result.Files = funcMain2(p3.Files, result.Files); + result.Id = p3.Id; + return result; + + } + public static Expression> ProjectToBrand => p7 => new Brand() + { + Name = p7.Name, + Description = p7.Description, + HasSpecialPage = p7.HasSpecialPage, + PageUrl = p7.PageUrl, + Files = p7.Files.Select(p8 => new BrandStorageFile() + { + Name = p8.Name, + FileLocation = p8.FileLocation, + FileName = p8.FileName, + IsHeader = p8.IsHeader, + IsPrimary = p8.IsPrimary, + FileType = p8.FileType, + Id = p8.Id + }).ToList(), + Id = p7.Id + }; + public static BrandLDto AdaptToLDto(this Brand p9) + { + return p9 == null ? null : new BrandLDto() + { + Name = p9.Name, + Description = p9.Description, + HasSpecialPage = p9.HasSpecialPage, + PageUrl = p9.PageUrl, + Files = funcMain3(p9.Files), + Id = p9.Id + }; + } + public static BrandLDto AdaptTo(this Brand p11, BrandLDto p12) + { + if (p11 == null) + { + return null; + } + BrandLDto result = p12 ?? new BrandLDto(); + + result.Name = p11.Name; + result.Description = p11.Description; + result.HasSpecialPage = p11.HasSpecialPage; + result.PageUrl = p11.PageUrl; + result.Files = funcMain4(p11.Files, result.Files); + result.Id = p11.Id; + return result; + + } + public static Expression> ProjectToLDto => p15 => new BrandLDto() + { + Name = p15.Name, + Description = p15.Description, + HasSpecialPage = p15.HasSpecialPage, + PageUrl = p15.PageUrl, + Files = p15.Files.Select(p16 => new StorageFileSDto() + { + Name = p16.Name, + FileLocation = p16.FileLocation, + FileName = p16.FileName, + IsHeader = p16.IsHeader, + IsPrimary = p16.IsPrimary, + FileType = p16.FileType, + Id = p16.Id + }).ToList(), + Id = p15.Id + }; + public static Brand AdaptToBrand(this BrandSDto p17) + { + return p17 == null ? null : new Brand() + { + Name = p17.Name, + Description = p17.Description, + HasSpecialPage = p17.HasSpecialPage, + PageUrl = p17.PageUrl, + Id = p17.Id + }; + } + public static Brand AdaptTo(this BrandSDto p18, Brand p19) + { + if (p18 == null) + { + return null; + } + Brand result = p19 ?? new Brand(); + + result.Name = p18.Name; + result.Description = p18.Description; + result.HasSpecialPage = p18.HasSpecialPage; + result.PageUrl = p18.PageUrl; + result.Id = p18.Id; + return result; + + } + public static BrandSDto AdaptToSDto(this Brand p20) + { + return p20 == null ? null : new BrandSDto() + { + Name = p20.Name, + Description = p20.Description, + HasSpecialPage = p20.HasSpecialPage, + PageUrl = p20.PageUrl, + HeaderFileName = p20.Files.Count > 0 && p20.Files.Any(funcMain5) ? p20.Files.FirstOrDefault(funcMain6).FileName : string.Empty, + Id = p20.Id + }; + } + public static BrandSDto AdaptTo(this Brand p21, BrandSDto p22) + { + if (p21 == null) + { + return null; + } + BrandSDto result = p22 ?? new BrandSDto(); + + result.Name = p21.Name; + result.Description = p21.Description; + result.HasSpecialPage = p21.HasSpecialPage; + result.PageUrl = p21.PageUrl; + result.HeaderFileName = p21.Files.Count > 0 && p21.Files.Any(funcMain5) ? p21.Files.FirstOrDefault(funcMain6).FileName : string.Empty; + result.Id = p21.Id; + return result; + + } + public static Expression> ProjectToSDto => p23 => new BrandSDto() + { + Name = p23.Name, + Description = p23.Description, + HasSpecialPage = p23.HasSpecialPage, + PageUrl = p23.PageUrl, + HeaderFileName = p23.Files.Count > 0 && p23.Files.Any(f => f.IsHeader) ? p23.Files.FirstOrDefault(f => f.IsHeader).FileName : string.Empty, + Id = p23.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + StorageFileSDto item = p2[i]; + result.Add(item == null ? null : new BrandStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + StorageFileSDto item = p5[i]; + result.Add(item == null ? null : new BrandStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + BrandStorageFile item = p10[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p13, List p14) + { + if (p13 == null) + { + return null; + } + List result = new List(p13.Count); + + int i = 0; + int len = p13.Count; + + while (i < len) + { + BrandStorageFile item = p13[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static bool funcMain5(BrandStorageFile f) + { + return f.IsHeader; + } + + private static bool funcMain6(BrandStorageFile f) + { + return f.IsHeader; + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/BrandStorageFileMapper.g.cs b/NetinaShop.Domain/Mappers/BrandStorageFileMapper.g.cs new file mode 100644 index 0000000..633543a --- /dev/null +++ b/NetinaShop.Domain/Mappers/BrandStorageFileMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class BrandStorageFileMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/CategoryDiscountMapper.g.cs b/NetinaShop.Domain/Mappers/CategoryDiscountMapper.g.cs new file mode 100644 index 0000000..dcbff66 --- /dev/null +++ b/NetinaShop.Domain/Mappers/CategoryDiscountMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class CategoryDiscountMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/CategoryMapper.g.cs b/NetinaShop.Domain/Mappers/CategoryMapper.g.cs new file mode 100644 index 0000000..05f58cd --- /dev/null +++ b/NetinaShop.Domain/Mappers/CategoryMapper.g.cs @@ -0,0 +1,405 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Categories; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class CategoryMapper + { + public static Category AdaptToCategory(this CategoryLDto p1) + { + return p1 == null ? null : new Category() + { + Name = p1.Name, + Description = p1.Description, + ParentId = p1.ParentId, + Children = funcMain1(p1.Children), + Files = funcMain2(p1.Files), + Id = p1.Id + }; + } + public static Category AdaptTo(this CategoryLDto p4, Category p5) + { + if (p4 == null) + { + return null; + } + Category result = p5 ?? new Category(); + + result.Name = p4.Name; + result.Description = p4.Description; + result.ParentId = p4.ParentId; + result.Children = funcMain3(p4.Children, result.Children); + result.Files = funcMain4(p4.Files, result.Files); + result.Id = p4.Id; + return result; + + } + public static Expression> ProjectToCategory => p10 => new Category() + { + Name = p10.Name, + Description = p10.Description, + ParentId = p10.ParentId, + Children = p10.Children.Select(p11 => new Category() + { + Name = p11.Name, + Description = p11.Description, + ParentId = p11.ParentId, + Id = p11.Id + }).ToList(), + Files = p10.Files.Select(p12 => new CategoryStorageFile() + { + Name = p12.Name, + FileLocation = p12.FileLocation, + FileName = p12.FileName, + IsHeader = p12.IsHeader, + IsPrimary = p12.IsPrimary, + FileType = p12.FileType, + Id = p12.Id + }).ToList(), + Id = p10.Id + }; + public static CategoryLDto AdaptToLDto(this Category p13) + { + return p13 == null ? null : new CategoryLDto() + { + Name = p13.Name, + Description = p13.Description, + ParentId = p13.ParentId, + Children = funcMain5(p13.Children), + Files = funcMain6(p13.Files), + Id = p13.Id + }; + } + public static CategoryLDto AdaptTo(this Category p16, CategoryLDto p17) + { + if (p16 == null) + { + return null; + } + CategoryLDto result = p17 ?? new CategoryLDto(); + + result.Name = p16.Name; + result.Description = p16.Description; + result.ParentId = p16.ParentId; + result.Children = funcMain7(p16.Children, result.Children); + result.Files = funcMain8(p16.Files, result.Files); + result.Id = p16.Id; + return result; + + } + public static Expression> ProjectToLDto => p22 => new CategoryLDto() + { + Name = p22.Name, + Description = p22.Description, + ParentId = p22.ParentId, + Children = p22.Children.Select(p23 => new CategorySDto() + { + Name = p23.Name, + Description = p23.Description, + ParentId = p23.ParentId, + Id = p23.Id + }).ToList(), + Files = p22.Files.Select(p24 => new StorageFileSDto() + { + Name = p24.Name, + FileLocation = p24.FileLocation, + FileName = p24.FileName, + IsHeader = p24.IsHeader, + IsPrimary = p24.IsPrimary, + FileType = p24.FileType, + Id = p24.Id + }).ToList(), + Id = p22.Id + }; + public static Category AdaptToCategory(this CategorySDto p25) + { + return p25 == null ? null : new Category() + { + Name = p25.Name, + Description = p25.Description, + ParentId = p25.ParentId, + Id = p25.Id + }; + } + public static Category AdaptTo(this CategorySDto p26, Category p27) + { + if (p26 == null) + { + return null; + } + Category result = p27 ?? new Category(); + + result.Name = p26.Name; + result.Description = p26.Description; + result.ParentId = p26.ParentId; + result.Id = p26.Id; + return result; + + } + public static CategorySDto AdaptToSDto(this Category p28) + { + return p28 == null ? null : new CategorySDto() + { + Name = p28.Name, + Description = p28.Description, + ParentId = p28.ParentId, + Id = p28.Id + }; + } + public static CategorySDto AdaptTo(this Category p29, CategorySDto p30) + { + if (p29 == null) + { + return null; + } + CategorySDto result = p30 ?? new CategorySDto(); + + result.Name = p29.Name; + result.Description = p29.Description; + result.ParentId = p29.ParentId; + result.Id = p29.Id; + return result; + + } + public static Expression> ProjectToSDto => p31 => new CategorySDto() + { + Name = p31.Name, + Description = p31.Description, + ParentId = p31.ParentId, + Id = p31.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + CategorySDto item = p2[i]; + result.Add(item == null ? null : new Category() + { + Name = item.Name, + Description = item.Description, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p3) + { + if (p3 == null) + { + return null; + } + List result = new List(p3.Count); + + int i = 0; + int len = p3.Count; + + while (i < len) + { + StorageFileSDto item = p3[i]; + result.Add(item == null ? null : new CategoryStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p6, List p7) + { + if (p6 == null) + { + return null; + } + List result = new List(p6.Count); + + int i = 0; + int len = p6.Count; + + while (i < len) + { + CategorySDto item = p6[i]; + result.Add(item == null ? null : new Category() + { + Name = item.Name, + Description = item.Description, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p8, List p9) + { + if (p8 == null) + { + return null; + } + List result = new List(p8.Count); + + int i = 0; + int len = p8.Count; + + while (i < len) + { + StorageFileSDto item = p8[i]; + result.Add(item == null ? null : new CategoryStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain5(List p14) + { + if (p14 == null) + { + return null; + } + List result = new List(p14.Count); + + int i = 0; + int len = p14.Count; + + while (i < len) + { + Category item = p14[i]; + result.Add(item == null ? null : new CategorySDto() + { + Name = item.Name, + Description = item.Description, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain6(List p15) + { + if (p15 == null) + { + return null; + } + List result = new List(p15.Count); + + int i = 0; + int len = p15.Count; + + while (i < len) + { + CategoryStorageFile item = p15[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain7(List p18, List p19) + { + if (p18 == null) + { + return null; + } + List result = new List(p18.Count); + + int i = 0; + int len = p18.Count; + + while (i < len) + { + Category item = p18[i]; + result.Add(item == null ? null : new CategorySDto() + { + Name = item.Name, + Description = item.Description, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain8(List p20, List p21) + { + if (p20 == null) + { + return null; + } + List result = new List(p20.Count); + + int i = 0; + int len = p20.Count; + + while (i < len) + { + CategoryStorageFile item = p20[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/CategoryStorageFileMapper.g.cs b/NetinaShop.Domain/Mappers/CategoryStorageFileMapper.g.cs new file mode 100644 index 0000000..8b15157 --- /dev/null +++ b/NetinaShop.Domain/Mappers/CategoryStorageFileMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class CategoryStorageFileMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/DiscountMapper.g.cs b/NetinaShop.Domain/Mappers/DiscountMapper.g.cs new file mode 100644 index 0000000..5f57af0 --- /dev/null +++ b/NetinaShop.Domain/Mappers/DiscountMapper.g.cs @@ -0,0 +1,276 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Discounts; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class DiscountMapper + { + public static Discount AdaptToDiscount(this DiscountLDto p1) + { + return p1 == null ? null : new Discount() + { + Code = p1.Code, + DiscountPercent = p1.DiscountPercent, + DiscountAmount = p1.DiscountAmount, + HasCode = p1.HasCode, + AmountType = p1.AmountType, + Type = p1.Type, + Count = p1.Count, + StartDate = p1.StartDate, + ExpireDate = p1.ExpireDate, + PriceFloor = p1.PriceFloor, + HasPriceFloor = p1.HasPriceFloor, + PriceCeiling = p1.PriceCeiling, + HasPriceCeiling = p1.HasPriceCeiling, + IsInfinity = p1.IsInfinity, + UseCount = p1.UseCount, + IsForInvitation = p1.IsForInvitation, + Id = p1.Id + }; + } + public static Discount AdaptTo(this DiscountLDto p2, Discount p3) + { + if (p2 == null) + { + return null; + } + Discount result = p3 ?? new Discount(); + + result.Code = p2.Code; + result.DiscountPercent = p2.DiscountPercent; + result.DiscountAmount = p2.DiscountAmount; + result.HasCode = p2.HasCode; + result.AmountType = p2.AmountType; + result.Type = p2.Type; + result.Count = p2.Count; + result.StartDate = p2.StartDate; + result.ExpireDate = p2.ExpireDate; + result.PriceFloor = p2.PriceFloor; + result.HasPriceFloor = p2.HasPriceFloor; + result.PriceCeiling = p2.PriceCeiling; + result.HasPriceCeiling = p2.HasPriceCeiling; + result.IsInfinity = p2.IsInfinity; + result.UseCount = p2.UseCount; + result.IsForInvitation = p2.IsForInvitation; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToDiscount => p4 => new Discount() + { + Code = p4.Code, + DiscountPercent = p4.DiscountPercent, + DiscountAmount = p4.DiscountAmount, + HasCode = p4.HasCode, + AmountType = p4.AmountType, + Type = p4.Type, + Count = p4.Count, + StartDate = p4.StartDate, + ExpireDate = p4.ExpireDate, + PriceFloor = p4.PriceFloor, + HasPriceFloor = p4.HasPriceFloor, + PriceCeiling = p4.PriceCeiling, + HasPriceCeiling = p4.HasPriceCeiling, + IsInfinity = p4.IsInfinity, + UseCount = p4.UseCount, + IsForInvitation = p4.IsForInvitation, + Id = p4.Id + }; + public static DiscountLDto AdaptToLDto(this Discount p5) + { + return p5 == null ? null : new DiscountLDto() + { + Code = p5.Code, + DiscountPercent = p5.DiscountPercent, + DiscountAmount = p5.DiscountAmount, + HasCode = p5.HasCode, + AmountType = p5.AmountType, + Type = p5.Type, + Count = p5.Count, + StartDate = p5.StartDate, + ExpireDate = p5.ExpireDate, + PriceFloor = p5.PriceFloor, + HasPriceFloor = p5.HasPriceFloor, + PriceCeiling = p5.PriceCeiling, + HasPriceCeiling = p5.HasPriceCeiling, + IsInfinity = p5.IsInfinity, + UseCount = p5.UseCount, + IsForInvitation = p5.IsForInvitation, + Id = p5.Id + }; + } + public static DiscountLDto AdaptTo(this Discount p6, DiscountLDto p7) + { + if (p6 == null) + { + return null; + } + DiscountLDto result = p7 ?? new DiscountLDto(); + + result.Code = p6.Code; + result.DiscountPercent = p6.DiscountPercent; + result.DiscountAmount = p6.DiscountAmount; + result.HasCode = p6.HasCode; + result.AmountType = p6.AmountType; + result.Type = p6.Type; + result.Count = p6.Count; + result.StartDate = p6.StartDate; + result.ExpireDate = p6.ExpireDate; + result.PriceFloor = p6.PriceFloor; + result.HasPriceFloor = p6.HasPriceFloor; + result.PriceCeiling = p6.PriceCeiling; + result.HasPriceCeiling = p6.HasPriceCeiling; + result.IsInfinity = p6.IsInfinity; + result.UseCount = p6.UseCount; + result.IsForInvitation = p6.IsForInvitation; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToLDto => p8 => new DiscountLDto() + { + Code = p8.Code, + DiscountPercent = p8.DiscountPercent, + DiscountAmount = p8.DiscountAmount, + HasCode = p8.HasCode, + AmountType = p8.AmountType, + Type = p8.Type, + Count = p8.Count, + StartDate = p8.StartDate, + ExpireDate = p8.ExpireDate, + PriceFloor = p8.PriceFloor, + HasPriceFloor = p8.HasPriceFloor, + PriceCeiling = p8.PriceCeiling, + HasPriceCeiling = p8.HasPriceCeiling, + IsInfinity = p8.IsInfinity, + UseCount = p8.UseCount, + IsForInvitation = p8.IsForInvitation, + Id = p8.Id + }; + public static Discount AdaptToDiscount(this DiscountSDto p9) + { + return p9 == null ? null : new Discount() + { + Code = p9.Code, + DiscountPercent = p9.DiscountPercent, + DiscountAmount = p9.DiscountAmount, + HasCode = p9.HasCode, + AmountType = p9.AmountType, + Type = p9.Type, + Count = p9.Count, + StartDate = p9.StartDate, + ExpireDate = p9.ExpireDate, + PriceFloor = p9.PriceFloor, + HasPriceFloor = p9.HasPriceFloor, + PriceCeiling = p9.PriceCeiling, + HasPriceCeiling = p9.HasPriceCeiling, + IsInfinity = p9.IsInfinity, + UseCount = p9.UseCount, + IsForInvitation = p9.IsForInvitation, + Id = p9.Id + }; + } + public static Discount AdaptTo(this DiscountSDto p10, Discount p11) + { + if (p10 == null) + { + return null; + } + Discount result = p11 ?? new Discount(); + + result.Code = p10.Code; + result.DiscountPercent = p10.DiscountPercent; + result.DiscountAmount = p10.DiscountAmount; + result.HasCode = p10.HasCode; + result.AmountType = p10.AmountType; + result.Type = p10.Type; + result.Count = p10.Count; + result.StartDate = p10.StartDate; + result.ExpireDate = p10.ExpireDate; + result.PriceFloor = p10.PriceFloor; + result.HasPriceFloor = p10.HasPriceFloor; + result.PriceCeiling = p10.PriceCeiling; + result.HasPriceCeiling = p10.HasPriceCeiling; + result.IsInfinity = p10.IsInfinity; + result.UseCount = p10.UseCount; + result.IsForInvitation = p10.IsForInvitation; + result.Id = p10.Id; + return result; + + } + public static DiscountSDto AdaptToSDto(this Discount p12) + { + return p12 == null ? null : new DiscountSDto() + { + Code = p12.Code, + DiscountPercent = p12.DiscountPercent, + DiscountAmount = p12.DiscountAmount, + HasCode = p12.HasCode, + AmountType = p12.AmountType, + Type = p12.Type, + Count = p12.Count, + StartDate = p12.StartDate, + ExpireDate = p12.ExpireDate, + PriceFloor = p12.PriceFloor, + HasPriceFloor = p12.HasPriceFloor, + PriceCeiling = p12.PriceCeiling, + HasPriceCeiling = p12.HasPriceCeiling, + IsInfinity = p12.IsInfinity, + UseCount = p12.UseCount, + IsForInvitation = p12.IsForInvitation, + Id = p12.Id + }; + } + public static DiscountSDto AdaptTo(this Discount p13, DiscountSDto p14) + { + if (p13 == null) + { + return null; + } + DiscountSDto result = p14 ?? new DiscountSDto(); + + result.Code = p13.Code; + result.DiscountPercent = p13.DiscountPercent; + result.DiscountAmount = p13.DiscountAmount; + result.HasCode = p13.HasCode; + result.AmountType = p13.AmountType; + result.Type = p13.Type; + result.Count = p13.Count; + result.StartDate = p13.StartDate; + result.ExpireDate = p13.ExpireDate; + result.PriceFloor = p13.PriceFloor; + result.HasPriceFloor = p13.HasPriceFloor; + result.PriceCeiling = p13.PriceCeiling; + result.HasPriceCeiling = p13.HasPriceCeiling; + result.IsInfinity = p13.IsInfinity; + result.UseCount = p13.UseCount; + result.IsForInvitation = p13.IsForInvitation; + result.Id = p13.Id; + return result; + + } + public static Expression> ProjectToSDto => p15 => new DiscountSDto() + { + Code = p15.Code, + DiscountPercent = p15.DiscountPercent, + DiscountAmount = p15.DiscountAmount, + HasCode = p15.HasCode, + AmountType = p15.AmountType, + Type = p15.Type, + Count = p15.Count, + StartDate = p15.StartDate, + ExpireDate = p15.ExpireDate, + PriceFloor = p15.PriceFloor, + HasPriceFloor = p15.HasPriceFloor, + PriceCeiling = p15.PriceCeiling, + HasPriceCeiling = p15.HasPriceCeiling, + IsInfinity = p15.IsInfinity, + UseCount = p15.UseCount, + IsForInvitation = p15.IsForInvitation, + Id = p15.Id + }; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs b/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs new file mode 100644 index 0000000..01bd238 --- /dev/null +++ b/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs @@ -0,0 +1,66 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class ProductCategoryMapper + { + public static ProductCategory AdaptToProductCategory(this ProductCategorySDto p1) + { + return p1 == null ? null : new ProductCategory() + { + CategoryId = p1.CategoryId, + ProductId = p1.ProductId, + Id = p1.Id + }; + } + public static ProductCategory AdaptTo(this ProductCategorySDto p2, ProductCategory p3) + { + if (p2 == null) + { + return null; + } + ProductCategory result = p3 ?? new ProductCategory(); + + result.CategoryId = p2.CategoryId; + result.ProductId = p2.ProductId; + result.Id = p2.Id; + return result; + + } + public static ProductCategorySDto AdaptToSDto(this ProductCategory p4) + { + return p4 == null ? null : new ProductCategorySDto() + { + CategoryId = p4.CategoryId, + CategoryName = p4.Category == null ? null : p4.Category.Name, + ProductId = p4.ProductId, + Id = p4.Id + }; + } + public static ProductCategorySDto AdaptTo(this ProductCategory p5, ProductCategorySDto p6) + { + if (p5 == null) + { + return null; + } + ProductCategorySDto result = p6 ?? new ProductCategorySDto(); + + result.CategoryId = p5.CategoryId; + result.CategoryName = p5.Category == null ? null : p5.Category.Name; + result.ProductId = p5.ProductId; + result.Id = p5.Id; + return result; + + } + public static Expression> ProjectToSDto => p7 => new ProductCategorySDto() + { + CategoryId = p7.CategoryId, + CategoryName = p7.Category.Name, + ProductId = p7.ProductId, + Id = p7.Id + }; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductDiscountMapper.g.cs b/NetinaShop.Domain/Mappers/ProductDiscountMapper.g.cs new file mode 100644 index 0000000..1f338d3 --- /dev/null +++ b/NetinaShop.Domain/Mappers/ProductDiscountMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class ProductDiscountMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductMapper.g.cs b/NetinaShop.Domain/Mappers/ProductMapper.g.cs new file mode 100644 index 0000000..3dfab34 --- /dev/null +++ b/NetinaShop.Domain/Mappers/ProductMapper.g.cs @@ -0,0 +1,734 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class ProductMapper + { + public static Product AdaptToProduct(this ProductLDto p1) + { + return p1 == null ? null : new Product() + { + PersianName = p1.PersianName, + EnglishName = p1.EnglishName, + Summery = p1.Summery, + ExpertCheck = p1.ExpertCheck, + Tags = p1.Tags, + Warranty = p1.Warranty, + BrandId = p1.BrandId, + Specifications = funcMain1(p1.Specifications), + Reviews = funcMain2(p1.Reviews), + Categories = funcMain3(p1.Categories), + Files = funcMain4(p1.Files), + Id = p1.Id + }; + } + public static Product AdaptTo(this ProductLDto p6, Product p7) + { + if (p6 == null) + { + return null; + } + Product result = p7 ?? new Product(); + + result.PersianName = p6.PersianName; + result.EnglishName = p6.EnglishName; + result.Summery = p6.Summery; + result.ExpertCheck = p6.ExpertCheck; + result.Tags = p6.Tags; + result.Warranty = p6.Warranty; + result.BrandId = p6.BrandId; + result.Specifications = funcMain5(p6.Specifications, result.Specifications); + result.Reviews = funcMain6(p6.Reviews, result.Reviews); + result.Categories = funcMain7(p6.Categories, result.Categories); + result.Files = funcMain8(p6.Files, result.Files); + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToProduct => p16 => new Product() + { + PersianName = p16.PersianName, + EnglishName = p16.EnglishName, + Summery = p16.Summery, + ExpertCheck = p16.ExpertCheck, + Tags = p16.Tags, + Warranty = p16.Warranty, + BrandId = p16.BrandId, + Specifications = p16.Specifications.Select(p17 => new Specification() + { + Title = p17.Title, + Detail = p17.Detail, + Value = p17.Value, + IsFeature = p17.IsFeature, + ProductId = p17.ProductId, + ParentId = p17.ParentId, + Id = p17.Id + }).ToList(), + Reviews = p16.Reviews.Select(p18 => new Review() + { + Title = p18.Title, + Comment = p18.Comment, + Rate = p18.Rate, + IsBuyer = p18.IsBuyer, + ProductId = p18.ProductId, + UserId = p18.UserId, + Id = p18.Id + }).ToList(), + Categories = p16.Categories.Select(p19 => new ProductCategory() + { + CategoryId = p19.CategoryId, + ProductId = p19.ProductId, + Id = p19.Id + }).ToList(), + Files = p16.Files.Select(p20 => new ProductStorageFile() + { + Name = p20.Name, + FileLocation = p20.FileLocation, + FileName = p20.FileName, + IsHeader = p20.IsHeader, + IsPrimary = p20.IsPrimary, + FileType = p20.FileType, + Id = p20.Id + }).ToList(), + Id = p16.Id + }; + public static ProductLDto AdaptToLDto(this Product p21) + { + return p21 == null ? null : new ProductLDto() + { + PersianName = p21.PersianName, + EnglishName = p21.EnglishName, + Summery = p21.Summery, + ExpertCheck = p21.ExpertCheck, + Tags = p21.Tags, + Warranty = p21.Warranty, + BrandId = p21.BrandId, + Specifications = funcMain9(p21.Specifications), + Reviews = funcMain10(p21.Reviews), + Categories = funcMain11(p21.Categories), + Files = funcMain12(p21.Files), + Id = p21.Id + }; + } + public static ProductLDto AdaptTo(this Product p26, ProductLDto p27) + { + if (p26 == null) + { + return null; + } + ProductLDto result = p27 ?? new ProductLDto(); + + result.PersianName = p26.PersianName; + result.EnglishName = p26.EnglishName; + result.Summery = p26.Summery; + result.ExpertCheck = p26.ExpertCheck; + result.Tags = p26.Tags; + result.Warranty = p26.Warranty; + result.BrandId = p26.BrandId; + result.Specifications = funcMain13(p26.Specifications, result.Specifications); + result.Reviews = funcMain14(p26.Reviews, result.Reviews); + result.Categories = funcMain15(p26.Categories, result.Categories); + result.Files = funcMain16(p26.Files, result.Files); + result.Id = p26.Id; + return result; + + } + public static Expression> ProjectToLDto => p36 => new ProductLDto() + { + PersianName = p36.PersianName, + EnglishName = p36.EnglishName, + Summery = p36.Summery, + ExpertCheck = p36.ExpertCheck, + Tags = p36.Tags, + Warranty = p36.Warranty, + BrandId = p36.BrandId, + Specifications = p36.Specifications.Select(p37 => new SpecificationSDto() + { + Title = p37.Title, + Detail = p37.Detail, + Value = p37.Value, + IsFeature = p37.IsFeature, + ProductId = p37.ProductId, + ParentId = p37.ParentId, + Id = p37.Id + }).ToList(), + Reviews = p36.Reviews.Select(p38 => new ReviewSDto() + { + Title = p38.Title, + Comment = p38.Comment, + Rate = p38.Rate, + IsBuyer = p38.IsBuyer, + ProductId = p38.ProductId, + UserId = p38.UserId, + Id = p38.Id + }).ToList(), + Categories = p36.Categories.Select(p39 => new ProductCategorySDto() + { + CategoryId = p39.CategoryId, + CategoryName = p39.Category.Name, + ProductId = p39.ProductId, + Id = p39.Id + }).ToList(), + Files = p36.Files.Select(p40 => new StorageFileSDto() + { + Name = p40.Name, + FileLocation = p40.FileLocation, + FileName = p40.FileName, + IsHeader = p40.IsHeader, + IsPrimary = p40.IsPrimary, + FileType = p40.FileType, + Id = p40.Id + }).ToList(), + Id = p36.Id + }; + public static Product AdaptToProduct(this ProductSDto p41) + { + return p41 == null ? null : new Product() + { + PersianName = p41.PersianName, + EnglishName = p41.EnglishName, + Summery = p41.Summery, + ExpertCheck = p41.ExpertCheck, + Tags = p41.Tags, + Warranty = p41.Warranty, + BrandId = p41.BrandId, + Id = p41.Id + }; + } + public static Product AdaptTo(this ProductSDto p42, Product p43) + { + if (p42 == null) + { + return null; + } + Product result = p43 ?? new Product(); + + result.PersianName = p42.PersianName; + result.EnglishName = p42.EnglishName; + result.Summery = p42.Summery; + result.ExpertCheck = p42.ExpertCheck; + result.Tags = p42.Tags; + result.Warranty = p42.Warranty; + result.BrandId = p42.BrandId; + result.Id = p42.Id; + return result; + + } + public static ProductSDto AdaptToSDto(this Product p44) + { + return p44 == null ? null : new ProductSDto() + { + PersianName = p44.PersianName, + EnglishName = p44.EnglishName, + Summery = p44.Summery, + ExpertCheck = p44.ExpertCheck, + Tags = p44.Tags, + Warranty = p44.Warranty, + BrandId = p44.BrandId, + Id = p44.Id + }; + } + public static ProductSDto AdaptTo(this Product p45, ProductSDto p46) + { + if (p45 == null) + { + return null; + } + ProductSDto result = p46 ?? new ProductSDto(); + + result.PersianName = p45.PersianName; + result.EnglishName = p45.EnglishName; + result.Summery = p45.Summery; + result.ExpertCheck = p45.ExpertCheck; + result.Tags = p45.Tags; + result.Warranty = p45.Warranty; + result.BrandId = p45.BrandId; + result.Id = p45.Id; + return result; + + } + public static Expression> ProjectToSDto => p47 => new ProductSDto() + { + PersianName = p47.PersianName, + EnglishName = p47.EnglishName, + Summery = p47.Summery, + ExpertCheck = p47.ExpertCheck, + Tags = p47.Tags, + Warranty = p47.Warranty, + BrandId = p47.BrandId, + Id = p47.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + SpecificationSDto item = p2[i]; + result.Add(item == null ? null : new Specification() + { + Title = item.Title, + Detail = item.Detail, + Value = item.Value, + IsFeature = item.IsFeature, + ProductId = item.ProductId, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p3) + { + if (p3 == null) + { + return null; + } + List result = new List(p3.Count); + + int i = 0; + int len = p3.Count; + + while (i < len) + { + ReviewSDto item = p3[i]; + result.Add(item == null ? null : new Review() + { + Title = item.Title, + Comment = item.Comment, + Rate = item.Rate, + IsBuyer = item.IsBuyer, + ProductId = item.ProductId, + UserId = item.UserId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p4) + { + if (p4 == null) + { + return null; + } + List result = new List(p4.Count); + + int i = 0; + int len = p4.Count; + + while (i < len) + { + ProductCategorySDto item = p4[i]; + result.Add(item == null ? null : new ProductCategory() + { + CategoryId = item.CategoryId, + ProductId = item.ProductId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p5) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + StorageFileSDto item = p5[i]; + result.Add(item == null ? null : new ProductStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain5(List p8, List p9) + { + if (p8 == null) + { + return null; + } + List result = new List(p8.Count); + + int i = 0; + int len = p8.Count; + + while (i < len) + { + SpecificationSDto item = p8[i]; + result.Add(item == null ? null : new Specification() + { + Title = item.Title, + Detail = item.Detail, + Value = item.Value, + IsFeature = item.IsFeature, + ProductId = item.ProductId, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain6(List p10, List p11) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + ReviewSDto item = p10[i]; + result.Add(item == null ? null : new Review() + { + Title = item.Title, + Comment = item.Comment, + Rate = item.Rate, + IsBuyer = item.IsBuyer, + ProductId = item.ProductId, + UserId = item.UserId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain7(List p12, List p13) + { + if (p12 == null) + { + return null; + } + List result = new List(p12.Count); + + int i = 0; + int len = p12.Count; + + while (i < len) + { + ProductCategorySDto item = p12[i]; + result.Add(item == null ? null : new ProductCategory() + { + CategoryId = item.CategoryId, + ProductId = item.ProductId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain8(List p14, List p15) + { + if (p14 == null) + { + return null; + } + List result = new List(p14.Count); + + int i = 0; + int len = p14.Count; + + while (i < len) + { + StorageFileSDto item = p14[i]; + result.Add(item == null ? null : new ProductStorageFile() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain9(List p22) + { + if (p22 == null) + { + return null; + } + List result = new List(p22.Count); + + int i = 0; + int len = p22.Count; + + while (i < len) + { + Specification item = p22[i]; + result.Add(item == null ? null : new SpecificationSDto() + { + Title = item.Title, + Detail = item.Detail, + Value = item.Value, + IsFeature = item.IsFeature, + ProductId = item.ProductId, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain10(List p23) + { + if (p23 == null) + { + return null; + } + List result = new List(p23.Count); + + int i = 0; + int len = p23.Count; + + while (i < len) + { + Review item = p23[i]; + result.Add(item == null ? null : new ReviewSDto() + { + Title = item.Title, + Comment = item.Comment, + Rate = item.Rate, + IsBuyer = item.IsBuyer, + ProductId = item.ProductId, + UserId = item.UserId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain11(List p24) + { + if (p24 == null) + { + return null; + } + List result = new List(p24.Count); + + int i = 0; + int len = p24.Count; + + while (i < len) + { + ProductCategory item = p24[i]; + result.Add(item == null ? null : new ProductCategorySDto() + { + CategoryId = item.CategoryId, + CategoryName = item.Category == null ? null : item.Category.Name, + ProductId = item.ProductId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain12(List p25) + { + if (p25 == null) + { + return null; + } + List result = new List(p25.Count); + + int i = 0; + int len = p25.Count; + + while (i < len) + { + ProductStorageFile item = p25[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain13(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) + { + Specification item = p28[i]; + result.Add(item == null ? null : new SpecificationSDto() + { + Title = item.Title, + Detail = item.Detail, + Value = item.Value, + IsFeature = item.IsFeature, + ProductId = item.ProductId, + ParentId = item.ParentId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain14(List p30, List p31) + { + if (p30 == null) + { + return null; + } + List result = new List(p30.Count); + + int i = 0; + int len = p30.Count; + + while (i < len) + { + Review item = p30[i]; + result.Add(item == null ? null : new ReviewSDto() + { + Title = item.Title, + Comment = item.Comment, + Rate = item.Rate, + IsBuyer = item.IsBuyer, + ProductId = item.ProductId, + UserId = item.UserId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain15(List p32, List p33) + { + if (p32 == null) + { + return null; + } + List result = new List(p32.Count); + + int i = 0; + int len = p32.Count; + + while (i < len) + { + ProductCategory item = p32[i]; + result.Add(item == null ? null : new ProductCategorySDto() + { + CategoryId = item.CategoryId, + CategoryName = item.Category == null ? null : item.Category.Name, + ProductId = item.ProductId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain16(List p34, List p35) + { + if (p34 == null) + { + return null; + } + List result = new List(p34.Count); + + int i = 0; + int len = p34.Count; + + while (i < len) + { + ProductStorageFile item = p34[i]; + result.Add(item == null ? null : new StorageFileSDto() + { + Name = item.Name, + FileLocation = item.FileLocation, + FileName = item.FileName, + IsHeader = item.IsHeader, + IsPrimary = item.IsPrimary, + FileType = item.FileType, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductStorageFileMapper.g.cs b/NetinaShop.Domain/Mappers/ProductStorageFileMapper.g.cs new file mode 100644 index 0000000..43e7d32 --- /dev/null +++ b/NetinaShop.Domain/Mappers/ProductStorageFileMapper.g.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.Mappers +{ + public static partial class ProductStorageFileMapper + { + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ReviewMapper.g.cs b/NetinaShop.Domain/Mappers/ReviewMapper.g.cs new file mode 100644 index 0000000..080d0ee --- /dev/null +++ b/NetinaShop.Domain/Mappers/ReviewMapper.g.cs @@ -0,0 +1,83 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class ReviewMapper + { + public static Review AdaptToReview(this ReviewSDto p1) + { + return p1 == null ? null : new Review() + { + Title = p1.Title, + Comment = p1.Comment, + Rate = p1.Rate, + IsBuyer = p1.IsBuyer, + ProductId = p1.ProductId, + UserId = p1.UserId, + Id = p1.Id + }; + } + public static Review AdaptTo(this ReviewSDto p2, Review p3) + { + if (p2 == null) + { + return null; + } + Review result = p3 ?? new Review(); + + result.Title = p2.Title; + result.Comment = p2.Comment; + result.Rate = p2.Rate; + result.IsBuyer = p2.IsBuyer; + result.ProductId = p2.ProductId; + result.UserId = p2.UserId; + result.Id = p2.Id; + return result; + + } + public static ReviewSDto AdaptToSDto(this Review p4) + { + return p4 == null ? null : new ReviewSDto() + { + Title = p4.Title, + Comment = p4.Comment, + Rate = p4.Rate, + IsBuyer = p4.IsBuyer, + ProductId = p4.ProductId, + UserId = p4.UserId, + Id = p4.Id + }; + } + public static ReviewSDto AdaptTo(this Review p5, ReviewSDto p6) + { + if (p5 == null) + { + return null; + } + ReviewSDto result = p6 ?? new ReviewSDto(); + + result.Title = p5.Title; + result.Comment = p5.Comment; + result.Rate = p5.Rate; + result.IsBuyer = p5.IsBuyer; + result.ProductId = p5.ProductId; + result.UserId = p5.UserId; + result.Id = p5.Id; + return result; + + } + public static Expression> ProjectToSDto => p7 => new ReviewSDto() + { + Title = p7.Title, + Comment = p7.Comment, + Rate = p7.Rate, + IsBuyer = p7.IsBuyer, + ProductId = p7.ProductId, + UserId = p7.UserId, + Id = p7.Id + }; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ShippingMapper.g.cs b/NetinaShop.Domain/Mappers/ShippingMapper.g.cs new file mode 100644 index 0000000..ec89be1 --- /dev/null +++ b/NetinaShop.Domain/Mappers/ShippingMapper.g.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class ShippingMapper + { + public static Shipping AdaptToShipping(this ShippingSDto p1) + { + return p1 == null ? null : new Shipping() {Id = p1.Id}; + } + public static Shipping AdaptTo(this ShippingSDto p2, Shipping p3) + { + if (p2 == null) + { + return null; + } + Shipping result = p3 ?? new Shipping(); + + result.Id = p2.Id; + return result; + + } + public static ShippingSDto AdaptToSDto(this Shipping p4) + { + return p4 == null ? null : new ShippingSDto() {Id = p4.Id}; + } + public static ShippingSDto AdaptTo(this Shipping p5, ShippingSDto p6) + { + if (p5 == null) + { + return null; + } + ShippingSDto result = p6 ?? new ShippingSDto(); + + result.Id = p5.Id; + return result; + + } + public static Expression> ProjectToSDto => p7 => new ShippingSDto() {Id = p7.Id}; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/SpecificationMapper.g.cs b/NetinaShop.Domain/Mappers/SpecificationMapper.g.cs new file mode 100644 index 0000000..bfdc311 --- /dev/null +++ b/NetinaShop.Domain/Mappers/SpecificationMapper.g.cs @@ -0,0 +1,83 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class SpecificationMapper + { + public static Specification AdaptToSpecification(this SpecificationSDto p1) + { + return p1 == null ? null : new Specification() + { + Title = p1.Title, + Detail = p1.Detail, + Value = p1.Value, + IsFeature = p1.IsFeature, + ProductId = p1.ProductId, + ParentId = p1.ParentId, + Id = p1.Id + }; + } + public static Specification AdaptTo(this SpecificationSDto p2, Specification p3) + { + if (p2 == null) + { + return null; + } + Specification result = p3 ?? new Specification(); + + result.Title = p2.Title; + result.Detail = p2.Detail; + result.Value = p2.Value; + result.IsFeature = p2.IsFeature; + result.ProductId = p2.ProductId; + result.ParentId = p2.ParentId; + result.Id = p2.Id; + return result; + + } + public static SpecificationSDto AdaptToSDto(this Specification p4) + { + return p4 == null ? null : new SpecificationSDto() + { + Title = p4.Title, + Detail = p4.Detail, + Value = p4.Value, + IsFeature = p4.IsFeature, + ProductId = p4.ProductId, + ParentId = p4.ParentId, + Id = p4.Id + }; + } + public static SpecificationSDto AdaptTo(this Specification p5, SpecificationSDto p6) + { + if (p5 == null) + { + return null; + } + SpecificationSDto result = p6 ?? new SpecificationSDto(); + + result.Title = p5.Title; + result.Detail = p5.Detail; + result.Value = p5.Value; + result.IsFeature = p5.IsFeature; + result.ProductId = p5.ProductId; + result.ParentId = p5.ParentId; + result.Id = p5.Id; + return result; + + } + public static Expression> ProjectToSDto => p7 => new SpecificationSDto() + { + Title = p7.Title, + Detail = p7.Detail, + Value = p7.Value, + IsFeature = p7.IsFeature, + ProductId = p7.ProductId, + ParentId = p7.ParentId, + Id = p7.Id + }; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/StorageFileMapper.g.cs b/NetinaShop.Domain/Mappers/StorageFileMapper.g.cs new file mode 100644 index 0000000..7d09b46 --- /dev/null +++ b/NetinaShop.Domain/Mappers/StorageFileMapper.g.cs @@ -0,0 +1,83 @@ +using System; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.StorageFiles; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class StorageFileMapper + { + public static StorageFile AdaptToStorageFile(this StorageFileSDto p1) + { + return p1 == null ? null : new StorageFile() + { + Name = p1.Name, + FileLocation = p1.FileLocation, + FileName = p1.FileName, + IsHeader = p1.IsHeader, + IsPrimary = p1.IsPrimary, + FileType = p1.FileType, + Id = p1.Id + }; + } + public static StorageFile AdaptTo(this StorageFileSDto p2, StorageFile p3) + { + if (p2 == null) + { + return null; + } + StorageFile result = p3 ?? new StorageFile(); + + result.Name = p2.Name; + result.FileLocation = p2.FileLocation; + result.FileName = p2.FileName; + result.IsHeader = p2.IsHeader; + result.IsPrimary = p2.IsPrimary; + result.FileType = p2.FileType; + result.Id = p2.Id; + return result; + + } + public static StorageFileSDto AdaptToSDto(this StorageFile p4) + { + return p4 == null ? null : new StorageFileSDto() + { + Name = p4.Name, + FileLocation = p4.FileLocation, + FileName = p4.FileName, + IsHeader = p4.IsHeader, + IsPrimary = p4.IsPrimary, + FileType = p4.FileType, + Id = p4.Id + }; + } + public static StorageFileSDto AdaptTo(this StorageFile p5, StorageFileSDto p6) + { + if (p5 == null) + { + return null; + } + StorageFileSDto result = p6 ?? new StorageFileSDto(); + + result.Name = p5.Name; + result.FileLocation = p5.FileLocation; + result.FileName = p5.FileName; + result.IsHeader = p5.IsHeader; + result.IsPrimary = p5.IsPrimary; + result.FileType = p5.FileType; + result.Id = p5.Id; + return result; + + } + public static Expression> ProjectToSDto => p7 => new StorageFileSDto() + { + Name = p7.Name, + FileLocation = p7.FileLocation, + FileName = p7.FileName, + IsHeader = p7.IsHeader, + IsPrimary = p7.IsPrimary, + FileType = p7.FileType, + Id = p7.Id + }; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/MappingRegister.cs b/NetinaShop.Domain/MappingRegister.cs deleted file mode 100644 index fe1f588..0000000 --- a/NetinaShop.Domain/MappingRegister.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace NetinaShop.Domain; - -public class MappingRegister : ICodeGenerationRegister -{ - public void Register(CodeGenerationConfig config) - { - //config.AdaptTwoWays("[name]SDto", MapType.Map | MapType.MapToTarget | MapType.Projection) - // .AlterType(); - } - -} \ No newline at end of file diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs new file mode 100644 index 0000000..794be12 --- /dev/null +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -0,0 +1,17 @@ +using NetinaShop.Domain.Entities.Brands; + +namespace NetinaShop.Domain; + +public class MapsterRegister : IRegister +{ + public void Register(TypeAdapterConfig config) + { + config.NewConfig() + .Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f=>f.IsHeader) ? o.Files.FirstOrDefault(f=>f.IsHeader)!.FileName : string.Empty) + .TwoWays(); + + config.NewConfig() + .Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f => f.IsHeader) ? o.Files.FirstOrDefault(f => f.IsHeader)!.FileName : string.Empty) + .TwoWays(); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/NetinaShop.Domain.csproj b/NetinaShop.Domain/NetinaShop.Domain.csproj index 4fc64dd..5c97f52 100644 --- a/NetinaShop.Domain/NetinaShop.Domain.csproj +++ b/NetinaShop.Domain/NetinaShop.Domain.csproj @@ -38,7 +38,6 @@ - @@ -58,16 +57,23 @@ + + + + + + + diff --git a/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs new file mode 100644 index 0000000..14ccfee --- /dev/null +++ b/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs @@ -0,0 +1,28 @@ +using NetinaShop.Domain.Entities.Categories; +using NetinaShop.Repository.Repositories.Base; +using NetinaShop.Repository.Repositories.Base.Contracts; + +namespace NetinaShop.Repository.Handlers.Categories; + +public class CreateCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateCategoryCommand request, CancellationToken cancellationToken) + { + var ent = Category.Create(request.Name, request.Description); + if (request.ParentId != default) + ent.SetParent(request.ParentId); + foreach (var file in request.Files) + { + ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } + _repositoryWrapper.SetRepository().Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return ent.AdaptToLDto(); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs new file mode 100644 index 0000000..da49b33 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs @@ -0,0 +1,24 @@ +using NetinaShop.Domain.Entities.Categories; + +namespace NetinaShop.Repository.Handlers.Categories; + +public class DeleteCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteCategoryCommand request, CancellationToken cancellationToken) + { + + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(c => c.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Category not found", ApiResultStatusCode.NotFound); + _repositoryWrapper.SetRepository().Delete(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs b/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs new file mode 100644 index 0000000..41ad6fa --- /dev/null +++ b/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs @@ -0,0 +1,22 @@ +using NetinaShop.Domain.CommandQueries.Queries; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Categories; + +namespace NetinaShop.Repository.Handlers.Categories; + +public class GetCategoriesQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetCategoriesQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetCategoriesQuery request, CancellationToken cancellationToken) + { + return await _repositoryWrapper.SetRepository().TableNoTracking.OrderByDescending(b => b.CreatedAt) + .Skip(request.Page * 10).Take(10) + .Select(CategoryMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs b/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs new file mode 100644 index 0000000..4ff87ac --- /dev/null +++ b/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs @@ -0,0 +1,24 @@ +using NetinaShop.Domain.CommandQueries.Queries; +using NetinaShop.Domain.Entities.Categories; + +namespace NetinaShop.Repository.Handlers.Categories; + +public class GetCategoryQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetCategoryQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetCategoryQuery request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(b => b.Id == request.Id) + .Select(CategoryMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (ent == null) + throw new AppException("Category not found", ApiResultStatusCode.NotFound); + return ent; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs new file mode 100644 index 0000000..158197e --- /dev/null +++ b/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs @@ -0,0 +1,44 @@ +using NetinaShop.Domain.Entities.Categories; + +namespace NetinaShop.Repository.Handlers.Categories; + +public class UpdateCategoryCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateCategoryCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdateCategoryCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(c => c.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Category not found", ApiResultStatusCode.NotFound); + + var newEnt = Category.Create(request.Name, request.Description); + newEnt.Id = ent.Id; + if (request.ParentId != default) + newEnt.SetParent(request.ParentId); + + + var dbFiles = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(s => s.CategoryId == newEnt.Id).ToListAsync(cancellationToken); + foreach (var dbFile in dbFiles) + { + if (request.Files.Any(s => s.Id == dbFile.Id)) + { + _repositoryWrapper.SetRepository().Delete(dbFile); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + } + foreach (var file in request.Files.Where(f => f.Id == default)) + { + newEnt.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } + _repositoryWrapper.SetRepository().Add(newEnt); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs new file mode 100644 index 0000000..8bb2f9b --- /dev/null +++ b/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs @@ -0,0 +1,47 @@ +using NetinaShop.Repository.Repositories.Base; + +namespace NetinaShop.Repository.Handlers.Discounts; + +public class CreateDiscountCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateDiscountCommand request, CancellationToken cancellationToken) + { + switch (request.Type) + { + case DiscountType.All: + var ent = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, request.IsForInvitation); + _repositoryWrapper.SetRepository().Add(ent); + break; + case DiscountType.Category: + var catDis = CategoryDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, + request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, + request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, + request.IsForInvitation, request.CategoryId); + _repositoryWrapper.SetRepository().Add(catDis); + break; + + case DiscountType.Product: + var productDis = ProductDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, + request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, + request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, + request.IsForInvitation, request.ProductId); + _repositoryWrapper.SetRepository().Add(productDis); + break; + default: + var def = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, + request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, + request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, + request.IsForInvitation); + _repositoryWrapper.SetRepository().Add(def); + break; + } + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return request.Adapt(); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs new file mode 100644 index 0000000..ce0a0b7 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Discounts/DeleteDiscountCommandHandler.cs @@ -0,0 +1,22 @@ +namespace NetinaShop.Repository.Handlers.Discounts; + +public class DeleteDiscountCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteDiscountCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteDiscountCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Discount NotFound", ApiResultStatusCode.NotFound); + + _repositoryWrapper.SetRepository().Delete(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs b/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs new file mode 100644 index 0000000..4377a72 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Discounts/GetDiscountQueryHandler.cs @@ -0,0 +1,22 @@ +namespace NetinaShop.Repository.Handlers.Discounts; + +public class GetDiscountQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetDiscountQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetDiscountQuery request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(b => b.Id == request.Id) + .Select(DiscountMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (ent == null) + throw new AppException("Discount NotFound", ApiResultStatusCode.NotFound); + + return ent; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs b/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs new file mode 100644 index 0000000..46622be --- /dev/null +++ b/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs @@ -0,0 +1,19 @@ +namespace NetinaShop.Repository.Handlers.Discounts; + +public class GetDiscountsQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetDiscountsQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetDiscountsQuery request, CancellationToken cancellationToken) + { + return await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(b => b.CreatedAt) + .Skip(request.Page * 10).Take(10) + .Select(DiscountMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs new file mode 100644 index 0000000..196af7f --- /dev/null +++ b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs @@ -0,0 +1,52 @@ +namespace NetinaShop.Repository.Handlers.Discounts; + +public class UpdateDiscountCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdateDiscountCommand request, CancellationToken cancellationToken) + { + switch (request.Type) + { + case DiscountType.All: + var ent = await _repositoryWrapper.SetRepository().TableNoTracking.FirstOrDefaultAsync(d=>d.Id==request.Id,cancellationToken); + if (ent == null) + throw new AppException("Discount not found", ApiResultStatusCode.NotFound); + var newEnt = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, request.IsForInvitation); + newEnt.Id = ent.Id; + _repositoryWrapper.SetRepository().Update(newEnt); + break; + case DiscountType.Category: + var catEnt = await _repositoryWrapper.SetRepository().TableNoTracking.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken); + if (catEnt == null) + throw new AppException("Discount not found", ApiResultStatusCode.NotFound); + + var catDis = CategoryDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, + request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, + request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, + request.IsForInvitation, request.CategoryId); + catDis.Id = catEnt.Id; + _repositoryWrapper.SetRepository().Update(catDis); + break; + + case DiscountType.Product: + var productEnt = await _repositoryWrapper.SetRepository().TableNoTracking.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken); + if (productEnt == null) + throw new AppException("Discount not found", ApiResultStatusCode.NotFound); + + var productDis = ProductDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, + request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, + request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, + request.IsForInvitation, request.ProductId); + productDis.Id = productEnt.Id; + _repositoryWrapper.SetRepository().Update(productDis); + break; + } + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs new file mode 100644 index 0000000..a87b0c7 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs @@ -0,0 +1,36 @@ +namespace NetinaShop.Repository.Handlers.Products; + +public class CreateProductCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateProductCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(CreateProductCommand request, CancellationToken cancellationToken) + { + var ent = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck, + request.Tags, request.Warranty, request.BrandId); + foreach (var specification in request.Specifications) + { + ent.AddSpecification(specification.Title, specification.Detail, specification.Value, + specification.IsFeature, specification.ParentId); + } + + foreach (var category in request.Categories) + { + ent.AddCategory(category); + } + + foreach (var file in request.Files) + { + ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } + + _repositoryWrapper.SetRepository().Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return ent.AdaptToLDto(); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs new file mode 100644 index 0000000..6247318 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs @@ -0,0 +1,24 @@ +using NetinaShop.Repository.Repositories.Base; + +namespace NetinaShop.Repository.Handlers.Products; + +public class DeleteProductCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteProductCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteProductCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Product NotFound", ApiResultStatusCode.NotFound); + + _repositoryWrapper.SetRepository().Delete(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs b/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs new file mode 100644 index 0000000..152db43 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs @@ -0,0 +1,21 @@ +namespace NetinaShop.Repository.Handlers.Products; + +public class GetProductQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetProductQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetProductQuery request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(b => b.Id == request.Id) + .Select(ProductMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (ent == null) + throw new AppException("Product not found", ApiResultStatusCode.NotFound); + return ent; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs b/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs new file mode 100644 index 0000000..553267d --- /dev/null +++ b/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs @@ -0,0 +1,19 @@ +namespace NetinaShop.Repository.Handlers.Products; + +public class GetProductsQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetProductsQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetProductsQuery request, CancellationToken cancellationToken) + { + return await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(b => b.CreatedAt).Skip(request.Page * 10) + .Take(10) + .Select(ProductMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs new file mode 100644 index 0000000..1636067 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs @@ -0,0 +1,74 @@ +namespace NetinaShop.Repository.Handlers.Products; + +public class UpdateProductCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateProductCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdateProductCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(e => e.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Product not found", ApiResultStatusCode.NotFound); + + var newEnt = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck, + request.Tags, request.Warranty, request.BrandId); + newEnt.Id = ent.Id; + + var dbSpecifications = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken); + foreach (var dbSpecification in dbSpecifications) + { + if (request.Specifications.Any(s => s.Id == dbSpecification.Id)) + { + _repositoryWrapper.SetRepository().Delete(dbSpecification); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + } + foreach (var specification in request.Specifications.Where(s => s.Id == default)) + { + newEnt.AddSpecification(specification.Title, specification.Detail, specification.Value, specification.IsFeature, specification.ParentId); + } + + + var dbCats = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken); + foreach (var dbCat in dbCats) + { + if (request.Categories.Any(s => s == dbCat.CategoryId)) + { + _repositoryWrapper.SetRepository().Delete(dbCat); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + } + foreach (var category in request.Categories) + { + if (dbCats.Any(c => c.Id == category)) + newEnt.AddCategory(category); + } + + + + var dbFiles = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken); + foreach (var dbFile in dbFiles) + { + if (request.Files.Any(s => s.Id == dbFile.Id)) + { + _repositoryWrapper.SetRepository().Delete(dbFile); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + } + foreach (var file in request.Files.Where(f=>f.Id==default)) + { + newEnt.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); + } + _repositoryWrapper.SetRepository().Update(newEnt); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs new file mode 100644 index 0000000..88216fa --- /dev/null +++ b/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs @@ -0,0 +1,22 @@ +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Repository.Handlers.Warehouses; + +public class CreateShippingCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateShippingCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateShippingCommand request, CancellationToken cancellationToken) + { + var ent = Shipping.Create(request.Title, request.WarehouseName, request.IsFastShipping, request.IsShipBySeller, + request.IsOriginalWarehouse); + _repositoryWrapper.SetRepository().Add(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return ent.AdaptToSDto(); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs new file mode 100644 index 0000000..3be1018 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Warehouses/DeleteShippingCommandHandler.cs @@ -0,0 +1,24 @@ +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Repository.Handlers.Warehouses; + +public class DeleteShippingCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteShippingCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteShippingCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Shipping not found", ApiResultStatusCode.NotFound); + + _repositoryWrapper.SetRepository().Delete(ent); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs new file mode 100644 index 0000000..a7a821a --- /dev/null +++ b/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs @@ -0,0 +1,27 @@ +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Repository.Handlers.Warehouses; + +public class UpdateShippingCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateShippingCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdateShippingCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Shipping not found", ApiResultStatusCode.NotFound); + + var newEnt = Shipping.Create(request.Title, request.WarehouseName, request.IsFastShipping, request.IsShipBySeller, + request.IsOriginalWarehouse); + newEnt.Id = ent.Id; + _repositoryWrapper.SetRepository().Update(newEnt); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/NetinaShop.Repository.csproj b/NetinaShop.Repository/NetinaShop.Repository.csproj index bd09f1b..ac86000 100644 --- a/NetinaShop.Repository/NetinaShop.Repository.csproj +++ b/NetinaShop.Repository/NetinaShop.Repository.csproj @@ -28,9 +28,9 @@ + - @@ -41,6 +41,7 @@ + @@ -53,15 +54,27 @@ + + + + + + + + + + + + diff --git a/NetinaShop.Repository/Repositories/Base/BaseRepository.cs b/NetinaShop.Repository/Repositories/Base/BaseRepository.cs index 37810f8..a3780ec 100644 --- a/NetinaShop.Repository/Repositories/Base/BaseRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/BaseRepository.cs @@ -11,7 +11,10 @@ public virtual async ValueTask GetByIdAsync(CancellationToken cancellationToken, params object[] ids) { - return await Entities.FindAsync(ids, cancellationToken); + var founded = await Entities.FindAsync(ids, cancellationToken); + if (founded == null) + throw new AppException($"{nameof(T)} Not Found", ApiResultStatusCode.NotFound); + return founded; } #region Sync Methods @@ -19,6 +22,8 @@ public virtual T GetById(params object[] ids) { var ent = Entities.Find(ids); + if (ent == null) + throw new AppException($"{nameof(Product)} Not Found", ApiResultStatusCode.NotFound); Detach(ent); return ent; } @@ -31,8 +36,9 @@ public virtual void AddRange(IEnumerable entities) { - AssertExtensions.NotNull(entities, nameof(entities)); - Entities.AddRange(entities); + var apiEntities = entities as T[] ?? entities.ToArray(); + AssertExtensions.NotNull(apiEntities, nameof(entities)); + Entities.AddRange(apiEntities); } public virtual void Update(T entity) @@ -44,8 +50,9 @@ public virtual void UpdateRange(IEnumerable entities) { - AssertExtensions.NotNull(entities, nameof(entities)); - Entities.UpdateRange(entities); + var apiEntities = entities as T[] ?? entities.ToArray(); + AssertExtensions.NotNull(apiEntities, nameof(entities)); + Entities.UpdateRange(apiEntities); } public void HardDelete(T entity) @@ -93,8 +100,7 @@ { AssertExtensions.NotNull(entity, nameof(entity)); var entry = DbContext.Entry(entity); - if (entry != null) - entry.State = EntityState.Detached; + entry.State = EntityState.Detached; } public virtual void Attach(T entity) diff --git a/NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs b/NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs new file mode 100644 index 0000000..ee8f9e5 --- /dev/null +++ b/NetinaShop.Repository/Repositories/Entity/Abstracts/IDiscountRepository.cs @@ -0,0 +1,5 @@ +namespace NetinaShop.Repository.Repositories.Entity.Abstracts; + +public interface IDiscountRepository : IScopedDependency, IDisposable, IReadRepository, IWriteRepository +{ +} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs b/NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs new file mode 100644 index 0000000..e57398f --- /dev/null +++ b/NetinaShop.Repository/Repositories/Entity/Abstracts/IProductRepository.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Repository.Repositories.Entity.Abstracts; + +public interface IProductRepository : IScopedDependency , IDisposable, IReadRepository, IWriteRepository +{ + +} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs b/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs new file mode 100644 index 0000000..44b275d --- /dev/null +++ b/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs @@ -0,0 +1,12 @@ +using NetinaShop.Repository.Repositories.Base; +using System.Threading; + +namespace NetinaShop.Repository.Repositories.Entity; + +public class DiscountRepository : BaseRepository, IDiscountRepository +{ + + public DiscountRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService) + { + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Repositories/Entity/ProductRepository.cs b/NetinaShop.Repository/Repositories/Entity/ProductRepository.cs new file mode 100644 index 0000000..cd925ae --- /dev/null +++ b/NetinaShop.Repository/Repositories/Entity/ProductRepository.cs @@ -0,0 +1,11 @@ +namespace NetinaShop.Repository.Repositories.Entity; + +public class ProductRepository : BaseRepository, IProductRepository +{ + + public ProductRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService) + { + + } + +} \ No newline at end of file