complete entities

complete Dtos , Mappers , CQRS , ApiEndPoints
release
Amir Hossein Khademi 2023-12-20 10:37:44 +03:30
parent ed4410d191
commit 042c9fb9c7
101 changed files with 4635 additions and 73 deletions

View File

@ -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<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<BlogCategory>().TableNoTracking
.OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10)
.Select(BlogCategoryMapper.ProjectToSDto)
.ToListAsync(cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<BlogCategory>().TableNoTracking
.Where(b => b.Id == id)
.Select(BlogCategoryMapper.ProjectToLDto)
.FirstOrDefaultAsync(cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] BlogCategorySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = BlogCategory.Create(dto.Name,dto.Description);
repositoryWrapper.SetRepository<BlogCategory>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
// PUT:Update Entity
public async Task<IResult> Put([FromBody] BlogCategorySDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<BlogCategory>().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<BlogCategory>().Update(newEnt);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<BlogCategory>().TableNoTracking
.FirstOrDefaultAsync(b => b.Id == id, cancellationToken);
if (ent == null)
throw new AppException("Blog not found");
repositoryWrapper.SetRepository<BlogCategory>().Delete(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
}

View File

@ -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<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Blog>().TableNoTracking.OrderByDescending(b=>b.CreatedAt).Skip(page*10).Take(10).ToListAsync(cancellationToken));
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Blog>().TableNoTracking
.OrderByDescending(b=>b.CreatedAt)
.Skip(page*10).Take(10)
.Select(BlogMapper.ProjectToSDto).ToListAsync(cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Blog>().TableNoTracking.Where(b=>b.Id==id).FirstOrDefaultAsync(cancellationToken));
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Blog>().TableNoTracking
.Where(b=>b.Id==id)
.Select(BlogMapper.ProjectToLDto)
.FirstOrDefaultAsync(cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] Blog ent, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
public async Task<IResult> 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<Blog>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
// PUT:Update Entity
public async Task<IResult> Put([FromBody] Blog updated, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
public async Task<IResult> Put([FromBody] BlogLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<Blog>().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<Blog>().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<Blog>().Update(newEnt);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}

View File

@ -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<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Brand>().TableNoTracking
.OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10)
.Select(BrandMapper.ProjectToSDto)
.ToListAsync(cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Brand>()
.TableNoTracking.Where(b => b.Id == id)
.Select(BrandMapper.ProjectToLDto)
.FirstOrDefaultAsync(cancellationToken));
// POST:Create Entity
public async Task<IResult> 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<Brand>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
// PUT:Update Entity
public async Task<IResult> Put([FromBody] BrandLDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<Brand>().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<Brand>().Update(newEnt);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<Brand>().TableNoTracking
.FirstOrDefaultAsync(b => b.Id == id, cancellationToken);
if (ent == null)
throw new AppException("Brand not found");
repositoryWrapper.SetRepository<Brand>().Delete(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
}

View File

@ -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<IResult> 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<IResult> GetAsync(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetDiscountQuery(id), cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] CreateDiscountCommand request, IMediator mediator,
CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// PUT:Update Entity
public async Task<IResult> Put([FromBody] UpdateDiscountCommand request, IMediator mediator,
CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteDiscountCommand(id), cancellationToken));
}

View File

@ -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<IResult> 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<IResult> GetAsync(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetCategoryQuery(id),cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] CreateCategoryCommand request, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// PUT:Update Entity
public async Task<IResult> Put([FromBody] UpdateCategoryCommand request, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteCategoryCommand(id), cancellationToken));
}

View File

@ -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<IResult> 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<IResult> GetAsync(Guid id, IMediator mediator,CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new GetProductQuery(id),cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] CreateProductCommand request, IMediator mediator,
CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// PUT:Update Entity
public async Task<IResult> Put([FromBody] UpdateProductCommand request, IMediator mediator,
CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteProductCommand(id), cancellationToken));
}

View File

@ -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<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Shipping>().TableNoTracking.OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10).ToListAsync(cancellationToken));
// GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<Shipping>().TableNoTracking.Where(b => b.Id == id).FirstOrDefaultAsync(cancellationToken));
// POST:Create Entity
public async Task<IResult> Post([FromBody] CreateShippingCommand request, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// PUT:Update Entity
public async Task<IResult> Put([FromBody] UpdateShippingCommand request, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
// DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteShippingCommand(id), cancellationToken));
}

View File

@ -75,8 +75,15 @@
<Using Include="NetinaShop.Core.CoreServices.Abstracts" />
<Using Include="NetinaShop.Core.Models.Api" />
<Using Include="NetinaShop.Domain" />
<Using Include="NetinaShop.Domain.CommandQueries.Commands" />
<Using Include="NetinaShop.Domain.CommandQueries.Queries" />
<Using Include="NetinaShop.Domain.Dtos.LargDtos" />
<Using Include="NetinaShop.Domain.Dtos.RequestDtos" />
<Using Include="NetinaShop.Domain.Dtos.SmallDtos" />
<Using Include="NetinaShop.Domain.Entities.Categories" />
<Using Include="NetinaShop.Domain.Entities.Discounts" />
<Using Include="NetinaShop.Domain.Entities.Users" />
<Using Include="NetinaShop.Domain.Mappers" />
<Using Include="NetinaShop.Domain.Models.Settings" />
<Using Include="NetinaShop.Infrastructure" />
<Using Include="NetinaShop.Infrastructure.Models" />

View File

@ -18,7 +18,6 @@
<TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -0,0 +1,16 @@
namespace NetinaShop.Domain.CommandQueries.Commands;
public sealed record CreateCategoryCommand(
string Name,
string Description,
Guid ParentId,
List<StorageFileSDto> Files) : IRequest<CategoryLDto>;
public sealed record UpdateCategoryCommand(
Guid Id,
string Name,
string Description,
Guid ParentId,
List<StorageFileSDto> Files) : IRequest<bool>;
public sealed record DeleteCategoryCommand(Guid Id) : IRequest<bool>;

View File

@ -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<DiscountLDto>;
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<bool>;
public sealed record DeleteDiscountCommand(Guid Id) : IRequest<bool>;

View File

@ -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<Guid> Categories,
List<SpecificationSDto> Specifications,
List<StorageFileSDto> Files):IRequest<ProductLDto>;
public sealed record UpdateProductCommand(
Guid Id,
string PersianName,
string EnglishName,
string Summery,
string ExpertCheck,
string Tags,
string Warranty,
Guid BrandId,
string BrandNames,
List<Guid> Categories,
List<SpecificationSDto> Specifications,
List<StorageFileSDto> Files) : IRequest<bool>;
public sealed record DeleteProductCommand(Guid Id) : IRequest<bool>;

View File

@ -0,0 +1,19 @@
namespace NetinaShop.Domain.CommandQueries.Commands;
public sealed record CreateShippingCommand (
string Title,
string WarehouseName,
bool IsFastShipping ,
bool IsShipBySeller ,
bool IsOriginalWarehouse) : IRequest<ShippingSDto>;
public sealed record UpdateShippingCommand(
Guid Id,
string Title,
string WarehouseName,
bool IsFastShipping,
bool IsShipBySeller,
bool IsOriginalWarehouse) : IRequest<bool>;
public sealed record DeleteShippingCommand(
Guid Id) : IRequest<bool>;

View File

@ -0,0 +1,4 @@
namespace NetinaShop.Domain.CommandQueries.Queries;
public record GetCategoryQuery(Guid Id) : IRequest<CategoryLDto>;
public record GetCategoriesQuery(int Page = 0) : IRequest<List<CategorySDto>>;

View File

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

View File

@ -0,0 +1,5 @@
namespace NetinaShop.Domain.CommandQueries.Queries;
public sealed record GetProductQuery(Guid Id) : IRequest<ProductLDto>;
public sealed record GetProductsQuery(int Page = 0) : IRequest<List<ProductSDto>>;

View File

@ -0,0 +1,8 @@
namespace NetinaShop.Domain.Dtos.LargDtos;
public class BlogCategoryLDto : BaseDto<BlogCategoryLDto, BlogCategory>
{
public string Name { get; internal set; } = string.Empty;
public string Description { get; internal set; } = string.Empty;
public List<BlogSDto> Blogs { get; set; } = new();
}

View File

@ -0,0 +1,14 @@
namespace NetinaShop.Domain.Dtos.LargDtos;
public class BlogLDto : BaseDto<BlogLDto , Blog>
{
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<StorageFileSDto> Files { get; internal set; } = new();
}

View File

@ -0,0 +1,13 @@
using NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain.Dtos.LargDtos;
public class BrandLDto : BaseDto<BrandLDto,Brand>
{
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<StorageFileSDto> Files { get; internal set; } = new();
}

View File

@ -0,0 +1,10 @@
namespace NetinaShop.Domain.Dtos.LargDtos;
public class CategoryLDto : BaseDto<CategoryLDto, Category>
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public Guid ParentId { get; set; }
public List<CategorySDto> Children { get; set; } = new();
public List<StorageFileSDto> Files { get; internal set; } = new();
}

View File

@ -0,0 +1,23 @@
namespace NetinaShop.Domain.Dtos.LargDtos;
public class DiscountLDto : BaseDto<DiscountLDto,Discount>
{
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; }
}

View File

@ -0,0 +1,18 @@
namespace NetinaShop.Domain.Dtos.LargDtos;
public class ProductLDto : BaseDto<ProductLDto,Product>
{
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<SpecificationSDto> Specifications { get; set; } = new();
public List<ReviewSDto> Reviews { get; set; } = new();
public List<ProductCategorySDto> Categories { get; set; } = new();
public List<StorageFileSDto> Files { get; set; } = new();
}

View File

@ -0,0 +1,7 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class BlogCategorySDto : BaseDto<BlogCategorySDto , BlogCategory>
{
public string Name { get; internal set; } = string.Empty;
public string Description { get; internal set; } = string.Empty;
}

View File

@ -0,0 +1,16 @@
using NetinaShop.Domain.Entities.Blogs;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class BlogSDto : BaseDto<BlogSDto , Blog>
{
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;
}

View File

@ -0,0 +1,12 @@
using NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class BrandSDto : BaseDto<BrandSDto , Brand>
{
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;
}

View File

@ -0,0 +1,8 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class CategorySDto : BaseDto<CategorySDto , Category>
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public Guid ParentId { get; set; }
}

View File

@ -0,0 +1,23 @@
using NetinaShop.Domain.Entities.Discounts;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class DiscountSDto : BaseDto<DiscountSDto,Discount>
{
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; }
}

View File

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

View File

@ -0,0 +1,14 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class ProductSDto : BaseDto<ProductSDto, Product>
{
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;
}

View File

@ -0,0 +1,11 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class ReviewSDto : BaseDto<ReviewSDto, Review>
{
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; }
}

View File

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

View File

@ -0,0 +1,12 @@
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class SpecificationSDto : BaseDto<SpecificationSDto,Specification>
{
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; }
}

View File

@ -0,0 +1,13 @@
using NetinaShop.Domain.Entities.StorageFiles;
namespace NetinaShop.Domain.Dtos.SmallDtos;
public class StorageFileSDto : BaseDto<StorageFileSDto , StorageFile>
{
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; }
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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<Blog> Blogs { get; internal set; } = new();

View File

@ -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; }
}

View File

@ -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);
}
}

View File

@ -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; }

View File

@ -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; }
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -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);
}
}

View File

@ -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; }

View File

@ -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; }
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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; }

View File

@ -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; }
}

View File

@ -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; }

View File

@ -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; }

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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; }

View File

@ -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);
}
}

View File

@ -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<Func<BlogCategoryLDto, BlogCategory>> ProjectToBlogCategory => p7 => new BlogCategory()
{
Name = p7.Name,
Description = p7.Description,
Blogs = p7.Blogs.Select<BlogSDto, Blog>(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<Blog>(),
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<Func<BlogCategory, BlogCategoryLDto>> ProjectToLDto => p15 => new BlogCategoryLDto()
{
Name = p15.Name,
Description = p15.Description,
Blogs = p15.Blogs.Select<Blog, BlogSDto>(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<BlogStorageFile>(f => f.IsHeader) ? p16.Files.FirstOrDefault<BlogStorageFile>(f => f.IsHeader).FileName : string.Empty,
Id = p16.Id
}).ToList<BlogSDto>(),
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<Func<BlogCategory, BlogCategorySDto>> ProjectToSDto => p23 => new BlogCategorySDto()
{
Name = p23.Name,
Description = p23.Description,
Id = p23.Id
};
private static List<Blog> funcMain1(List<BlogSDto> p2)
{
if (p2 == null)
{
return null;
}
List<Blog> result = new List<Blog>(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<Blog> funcMain2(List<BlogSDto> p5, List<Blog> p6)
{
if (p5 == null)
{
return null;
}
List<Blog> result = new List<Blog>(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<BlogSDto> funcMain3(List<Blog> p10)
{
if (p10 == null)
{
return null;
}
List<BlogSDto> result = new List<BlogSDto>(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<BlogStorageFile>(funcMain4) ? item.Files.FirstOrDefault<BlogStorageFile>(funcMain5).FileName : string.Empty,
Id = item.Id
});
i++;
}
return result;
}
private static List<BlogSDto> funcMain6(List<Blog> p13, List<BlogSDto> p14)
{
if (p13 == null)
{
return null;
}
List<BlogSDto> result = new List<BlogSDto>(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<BlogStorageFile>(funcMain4) ? item.Files.FirstOrDefault<BlogStorageFile>(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;
}
}
}

View File

@ -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<Func<BlogLDto, Blog>> 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<StorageFileSDto, BlogStorageFile>(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<BlogStorageFile>(),
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<Func<Blog, BlogLDto>> 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<BlogStorageFile, StorageFileSDto>(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<StorageFileSDto>(),
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<BlogStorageFile>(funcMain6) ? p22.Files.FirstOrDefault<BlogStorageFile>(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<BlogStorageFile>(funcMain6) ? p23.Files.FirstOrDefault<BlogStorageFile>(funcMain7).FileName : string.Empty;
result.Id = p23.Id;
return result;
}
public static Expression<Func<Blog, BlogSDto>> 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<BlogStorageFile>(f => f.IsHeader) ? p25.Files.FirstOrDefault<BlogStorageFile>(f => f.IsHeader).FileName : string.Empty,
Id = p25.Id
};
private static List<BlogStorageFile> funcMain1(List<StorageFileSDto> p2)
{
if (p2 == null)
{
return null;
}
List<BlogStorageFile> result = new List<BlogStorageFile>(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<BlogStorageFile> funcMain2(List<StorageFileSDto> p5, List<BlogStorageFile> p6)
{
if (p5 == null)
{
return null;
}
List<BlogStorageFile> result = new List<BlogStorageFile>(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<StorageFileSDto> funcMain3(List<BlogStorageFile> p10)
{
if (p10 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(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<StorageFileSDto> funcMain4(List<BlogStorageFile> p13, List<StorageFileSDto> p14)
{
if (p13 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(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;
}
}
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.Mappers
{
public static partial class BlogStorageFileMapper
{
}
}

View File

@ -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<Func<BrandLDto, Brand>> ProjectToBrand => p7 => new Brand()
{
Name = p7.Name,
Description = p7.Description,
HasSpecialPage = p7.HasSpecialPage,
PageUrl = p7.PageUrl,
Files = p7.Files.Select<StorageFileSDto, BrandStorageFile>(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<BrandStorageFile>(),
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<Func<Brand, BrandLDto>> ProjectToLDto => p15 => new BrandLDto()
{
Name = p15.Name,
Description = p15.Description,
HasSpecialPage = p15.HasSpecialPage,
PageUrl = p15.PageUrl,
Files = p15.Files.Select<BrandStorageFile, StorageFileSDto>(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<StorageFileSDto>(),
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<BrandStorageFile>(funcMain5) ? p20.Files.FirstOrDefault<BrandStorageFile>(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<BrandStorageFile>(funcMain5) ? p21.Files.FirstOrDefault<BrandStorageFile>(funcMain6).FileName : string.Empty;
result.Id = p21.Id;
return result;
}
public static Expression<Func<Brand, BrandSDto>> ProjectToSDto => p23 => new BrandSDto()
{
Name = p23.Name,
Description = p23.Description,
HasSpecialPage = p23.HasSpecialPage,
PageUrl = p23.PageUrl,
HeaderFileName = p23.Files.Count > 0 && p23.Files.Any<BrandStorageFile>(f => f.IsHeader) ? p23.Files.FirstOrDefault<BrandStorageFile>(f => f.IsHeader).FileName : string.Empty,
Id = p23.Id
};
private static List<BrandStorageFile> funcMain1(List<StorageFileSDto> p2)
{
if (p2 == null)
{
return null;
}
List<BrandStorageFile> result = new List<BrandStorageFile>(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<BrandStorageFile> funcMain2(List<StorageFileSDto> p5, List<BrandStorageFile> p6)
{
if (p5 == null)
{
return null;
}
List<BrandStorageFile> result = new List<BrandStorageFile>(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<StorageFileSDto> funcMain3(List<BrandStorageFile> p10)
{
if (p10 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(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<StorageFileSDto> funcMain4(List<BrandStorageFile> p13, List<StorageFileSDto> p14)
{
if (p13 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(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;
}
}
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.Mappers
{
public static partial class BrandStorageFileMapper
{
}
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.Mappers
{
public static partial class CategoryDiscountMapper
{
}
}

View File

@ -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<Func<CategoryLDto, Category>> ProjectToCategory => p10 => new Category()
{
Name = p10.Name,
Description = p10.Description,
ParentId = p10.ParentId,
Children = p10.Children.Select<CategorySDto, Category>(p11 => new Category()
{
Name = p11.Name,
Description = p11.Description,
ParentId = p11.ParentId,
Id = p11.Id
}).ToList<Category>(),
Files = p10.Files.Select<StorageFileSDto, CategoryStorageFile>(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<CategoryStorageFile>(),
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<Func<Category, CategoryLDto>> ProjectToLDto => p22 => new CategoryLDto()
{
Name = p22.Name,
Description = p22.Description,
ParentId = p22.ParentId,
Children = p22.Children.Select<Category, CategorySDto>(p23 => new CategorySDto()
{
Name = p23.Name,
Description = p23.Description,
ParentId = p23.ParentId,
Id = p23.Id
}).ToList<CategorySDto>(),
Files = p22.Files.Select<CategoryStorageFile, StorageFileSDto>(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<StorageFileSDto>(),
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<Func<Category, CategorySDto>> ProjectToSDto => p31 => new CategorySDto()
{
Name = p31.Name,
Description = p31.Description,
ParentId = p31.ParentId,
Id = p31.Id
};
private static List<Category> funcMain1(List<CategorySDto> p2)
{
if (p2 == null)
{
return null;
}
List<Category> result = new List<Category>(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<CategoryStorageFile> funcMain2(List<StorageFileSDto> p3)
{
if (p3 == null)
{
return null;
}
List<CategoryStorageFile> result = new List<CategoryStorageFile>(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<Category> funcMain3(List<CategorySDto> p6, List<Category> p7)
{
if (p6 == null)
{
return null;
}
List<Category> result = new List<Category>(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<CategoryStorageFile> funcMain4(List<StorageFileSDto> p8, List<CategoryStorageFile> p9)
{
if (p8 == null)
{
return null;
}
List<CategoryStorageFile> result = new List<CategoryStorageFile>(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<CategorySDto> funcMain5(List<Category> p14)
{
if (p14 == null)
{
return null;
}
List<CategorySDto> result = new List<CategorySDto>(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<StorageFileSDto> funcMain6(List<CategoryStorageFile> p15)
{
if (p15 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(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<CategorySDto> funcMain7(List<Category> p18, List<CategorySDto> p19)
{
if (p18 == null)
{
return null;
}
List<CategorySDto> result = new List<CategorySDto>(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<StorageFileSDto> funcMain8(List<CategoryStorageFile> p20, List<StorageFileSDto> p21)
{
if (p20 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(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;
}
}
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.Mappers
{
public static partial class CategoryStorageFileMapper
{
}
}

View File

@ -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<Func<DiscountLDto, Discount>> 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<Func<Discount, DiscountLDto>> 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<Func<Discount, DiscountSDto>> 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
};
}
}

View File

@ -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<Func<ProductCategory, ProductCategorySDto>> ProjectToSDto => p7 => new ProductCategorySDto()
{
CategoryId = p7.CategoryId,
CategoryName = p7.Category.Name,
ProductId = p7.ProductId,
Id = p7.Id
};
}
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.Mappers
{
public static partial class ProductDiscountMapper
{
}
}

View File

@ -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<Func<ProductLDto, Product>> 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<SpecificationSDto, Specification>(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<Specification>(),
Reviews = p16.Reviews.Select<ReviewSDto, Review>(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<Review>(),
Categories = p16.Categories.Select<ProductCategorySDto, ProductCategory>(p19 => new ProductCategory()
{
CategoryId = p19.CategoryId,
ProductId = p19.ProductId,
Id = p19.Id
}).ToList<ProductCategory>(),
Files = p16.Files.Select<StorageFileSDto, ProductStorageFile>(p20 => new ProductStorageFile()
{
Name = p20.Name,
FileLocation = p20.FileLocation,
FileName = p20.FileName,
IsHeader = p20.IsHeader,
IsPrimary = p20.IsPrimary,
FileType = p20.FileType,
Id = p20.Id
}).ToList<ProductStorageFile>(),
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<Func<Product, ProductLDto>> 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<Specification, SpecificationSDto>(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<SpecificationSDto>(),
Reviews = p36.Reviews.Select<Review, ReviewSDto>(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<ReviewSDto>(),
Categories = p36.Categories.Select<ProductCategory, ProductCategorySDto>(p39 => new ProductCategorySDto()
{
CategoryId = p39.CategoryId,
CategoryName = p39.Category.Name,
ProductId = p39.ProductId,
Id = p39.Id
}).ToList<ProductCategorySDto>(),
Files = p36.Files.Select<ProductStorageFile, StorageFileSDto>(p40 => new StorageFileSDto()
{
Name = p40.Name,
FileLocation = p40.FileLocation,
FileName = p40.FileName,
IsHeader = p40.IsHeader,
IsPrimary = p40.IsPrimary,
FileType = p40.FileType,
Id = p40.Id
}).ToList<StorageFileSDto>(),
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<Func<Product, ProductSDto>> 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<Specification> funcMain1(List<SpecificationSDto> p2)
{
if (p2 == null)
{
return null;
}
List<Specification> result = new List<Specification>(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<Review> funcMain2(List<ReviewSDto> p3)
{
if (p3 == null)
{
return null;
}
List<Review> result = new List<Review>(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<ProductCategory> funcMain3(List<ProductCategorySDto> p4)
{
if (p4 == null)
{
return null;
}
List<ProductCategory> result = new List<ProductCategory>(p4.Count);
int i = 0;
int len = p4.Count;
while (i < len)
{
ProductCategorySDto item = p4[i];
result.Add(item == null ? null : new ProductCategory()
{
CategoryId = item.CategoryId,
ProductId = item.ProductId,
Id = item.Id
});
i++;
}
return result;
}
private static List<ProductStorageFile> funcMain4(List<StorageFileSDto> p5)
{
if (p5 == null)
{
return null;
}
List<ProductStorageFile> result = new List<ProductStorageFile>(p5.Count);
int i = 0;
int len = p5.Count;
while (i < len)
{
StorageFileSDto item = p5[i];
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<Specification> funcMain5(List<SpecificationSDto> p8, List<Specification> p9)
{
if (p8 == null)
{
return null;
}
List<Specification> result = new List<Specification>(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<Review> funcMain6(List<ReviewSDto> p10, List<Review> p11)
{
if (p10 == null)
{
return null;
}
List<Review> result = new List<Review>(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<ProductCategory> funcMain7(List<ProductCategorySDto> p12, List<ProductCategory> p13)
{
if (p12 == null)
{
return null;
}
List<ProductCategory> result = new List<ProductCategory>(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<ProductStorageFile> funcMain8(List<StorageFileSDto> p14, List<ProductStorageFile> p15)
{
if (p14 == null)
{
return null;
}
List<ProductStorageFile> result = new List<ProductStorageFile>(p14.Count);
int i = 0;
int len = p14.Count;
while (i < len)
{
StorageFileSDto item = p14[i];
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<SpecificationSDto> funcMain9(List<Specification> p22)
{
if (p22 == null)
{
return null;
}
List<SpecificationSDto> result = new List<SpecificationSDto>(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<ReviewSDto> funcMain10(List<Review> p23)
{
if (p23 == null)
{
return null;
}
List<ReviewSDto> result = new List<ReviewSDto>(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<ProductCategorySDto> funcMain11(List<ProductCategory> p24)
{
if (p24 == null)
{
return null;
}
List<ProductCategorySDto> result = new List<ProductCategorySDto>(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<StorageFileSDto> funcMain12(List<ProductStorageFile> p25)
{
if (p25 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(p25.Count);
int i = 0;
int len = p25.Count;
while (i < len)
{
ProductStorageFile item = p25[i];
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<SpecificationSDto> funcMain13(List<Specification> p28, List<SpecificationSDto> p29)
{
if (p28 == null)
{
return null;
}
List<SpecificationSDto> result = new List<SpecificationSDto>(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<ReviewSDto> funcMain14(List<Review> p30, List<ReviewSDto> p31)
{
if (p30 == null)
{
return null;
}
List<ReviewSDto> result = new List<ReviewSDto>(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<ProductCategorySDto> funcMain15(List<ProductCategory> p32, List<ProductCategorySDto> p33)
{
if (p32 == null)
{
return null;
}
List<ProductCategorySDto> result = new List<ProductCategorySDto>(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<StorageFileSDto> funcMain16(List<ProductStorageFile> p34, List<StorageFileSDto> p35)
{
if (p34 == null)
{
return null;
}
List<StorageFileSDto> result = new List<StorageFileSDto>(p34.Count);
int i = 0;
int len = p34.Count;
while (i < len)
{
ProductStorageFile item = p34[i];
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;
}
}
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Domain.Mappers
{
public static partial class ProductStorageFileMapper
{
}
}

View File

@ -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<Func<Review, ReviewSDto>> 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
};
}
}

View File

@ -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<Func<Shipping, ShippingSDto>> ProjectToSDto => p7 => new ShippingSDto() {Id = p7.Id};
}
}

View File

@ -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<Func<Specification, SpecificationSDto>> 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
};
}
}

View File

@ -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<Func<StorageFile, StorageFileSDto>> 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
};
}
}

View File

@ -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<ApplicationUser,ApplicationUserSDto>();
}
}

View File

@ -0,0 +1,17 @@
using NetinaShop.Domain.Entities.Brands;
namespace NetinaShop.Domain;
public class MapsterRegister : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig<Blog, BlogSDto>()
.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<Brand, BrandSDto>()
.Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f => f.IsHeader) ? o.Files.FirstOrDefault(f => f.IsHeader)!.FileName : string.Empty)
.TwoWays();
}
}

View File

@ -38,7 +38,6 @@
<ItemGroup>
<Folder Include="Dtos\LargDtos\" />
<Folder Include="Dtos\RequestDtos\" />
<Folder Include="Dtos\SmallDtos\" />
<Folder Include="Entities\StorageFiles\" />
<Folder Include="Models\Settings\" />
</ItemGroup>
@ -58,16 +57,23 @@
<ItemGroup>
<Using Include="Mapster" />
<Using Include="MediatR" />
<Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Microsoft.Extensions.Logging" />
<Using Include="NetinaShop.Common.Extensions" />
<Using Include="NetinaShop.Common.Models.Entity" />
<Using Include="NetinaShop.Common.Models.Mapper" />
<Using Include="NetinaShop.Domain.Dtos.LargDtos" />
<Using Include="NetinaShop.Domain.Dtos.SmallDtos" />
<Using Include="NetinaShop.Domain.Entities.Blogs" />
<Using Include="NetinaShop.Domain.Entities.Brands" />
<Using Include="NetinaShop.Domain.Entities.Categories" />
<Using Include="NetinaShop.Domain.Entities.Discounts" />
<Using Include="NetinaShop.Domain.Entities.Orders" />
<Using Include="NetinaShop.Domain.Entities.Products" />
<Using Include="NetinaShop.Domain.Entities.StorageFiles" />
<Using Include="NetinaShop.Domain.Entities.Users" />
<Using Include="NetinaShop.Domain.Entities.Warehouses" />
<Using Include="NetinaShop.Domain.Enums" />
<Using Include="System.ComponentModel.DataAnnotations" />
<Using Include="System.Diagnostics" />

View File

@ -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<CreateCategoryCommand,CategoryLDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public CreateCategoryCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<CategoryLDto> 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<Category>().Add(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.AdaptToLDto();
}
}

View File

@ -0,0 +1,24 @@
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class DeleteCategoryCommandHandler : IRequestHandler<DeleteCategoryCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public DeleteCategoryCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(DeleteCategoryCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Category>().TableNoTracking
.FirstOrDefaultAsync(c => c.Id == request.Id, cancellationToken);
if (ent == null)
throw new AppException("Category not found", ApiResultStatusCode.NotFound);
_repositoryWrapper.SetRepository<Category>().Delete(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -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<GetCategoriesQuery, List<CategorySDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetCategoriesQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<CategorySDto>> Handle(GetCategoriesQuery request, CancellationToken cancellationToken)
{
return await _repositoryWrapper.SetRepository<Category>().TableNoTracking.OrderByDescending(b => b.CreatedAt)
.Skip(request.Page * 10).Take(10)
.Select(CategoryMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
}
}

View File

@ -0,0 +1,24 @@
using NetinaShop.Domain.CommandQueries.Queries;
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class GetCategoryQueryHandler : IRequestHandler<GetCategoryQuery, CategoryLDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetCategoryQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<CategoryLDto> Handle(GetCategoryQuery request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Category>().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;
}
}

View File

@ -0,0 +1,44 @@
using NetinaShop.Domain.Entities.Categories;
namespace NetinaShop.Repository.Handlers.Categories;
public class UpdateCategoryCommandHandler : IRequestHandler<UpdateCategoryCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public UpdateCategoryCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(UpdateCategoryCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Category>().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<CategoryStorageFile>().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<CategoryStorageFile>().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<Category>().Add(newEnt);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,47 @@
using NetinaShop.Repository.Repositories.Base;
namespace NetinaShop.Repository.Handlers.Discounts;
public class CreateDiscountCommandHandler : IRequestHandler<CreateDiscountCommand , DiscountLDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public CreateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<DiscountLDto> 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<Discount>().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<CategoryDiscount>().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<ProductDiscount>().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<Discount>().Add(def);
break;
}
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return request.Adapt<DiscountLDto>();
}
}

View File

@ -0,0 +1,22 @@
namespace NetinaShop.Repository.Handlers.Discounts;
public class DeleteDiscountCommandHandler : IRequestHandler<DeleteDiscountCommand,bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public DeleteDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(DeleteDiscountCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Discount>().TableNoTracking
.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken);
if (ent == null)
throw new AppException("Discount NotFound", ApiResultStatusCode.NotFound);
_repositoryWrapper.SetRepository<Discount>().Delete(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,22 @@
namespace NetinaShop.Repository.Handlers.Discounts;
public class GetDiscountQueryHandler : IRequestHandler<GetDiscountQuery, DiscountLDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetDiscountQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<DiscountLDto> Handle(GetDiscountQuery request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Discount>().TableNoTracking
.Where(b => b.Id == request.Id)
.Select(DiscountMapper.ProjectToLDto)
.FirstOrDefaultAsync(cancellationToken);
if (ent == null)
throw new AppException("Discount NotFound", ApiResultStatusCode.NotFound);
return ent;
}
}

View File

@ -0,0 +1,19 @@
namespace NetinaShop.Repository.Handlers.Discounts;
public class GetDiscountsQueryHandler : IRequestHandler<GetDiscountsQuery, List<DiscountSDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetDiscountsQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<DiscountSDto>> Handle(GetDiscountsQuery request, CancellationToken cancellationToken)
{
return await _repositoryWrapper.SetRepository<Discount>().TableNoTracking
.OrderByDescending(b => b.CreatedAt)
.Skip(request.Page * 10).Take(10)
.Select(DiscountMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
}
}

View File

@ -0,0 +1,52 @@
namespace NetinaShop.Repository.Handlers.Discounts;
public class UpdateDiscountCommandHandler : IRequestHandler<UpdateDiscountCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public UpdateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(UpdateDiscountCommand request, CancellationToken cancellationToken)
{
switch (request.Type)
{
case DiscountType.All:
var ent = await _repositoryWrapper.SetRepository<Discount>().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<Discount>().Update(newEnt);
break;
case DiscountType.Category:
var catEnt = await _repositoryWrapper.SetRepository<CategoryDiscount>().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<CategoryDiscount>().Update(catDis);
break;
case DiscountType.Product:
var productEnt = await _repositoryWrapper.SetRepository<CategoryDiscount>().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<ProductDiscount>().Update(productDis);
break;
}
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,36 @@
namespace NetinaShop.Repository.Handlers.Products;
public class CreateProductCommandHandler : IRequestHandler<CreateProductCommand, ProductLDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public CreateProductCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<ProductLDto> Handle(CreateProductCommand request, CancellationToken cancellationToken)
{
var ent = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck,
request.Tags, request.Warranty, request.BrandId);
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<Product>().Add(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.AdaptToLDto();
}
}

View File

@ -0,0 +1,24 @@
using NetinaShop.Repository.Repositories.Base;
namespace NetinaShop.Repository.Handlers.Products;
public class DeleteProductCommandHandler : IRequestHandler<DeleteProductCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public DeleteProductCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(DeleteProductCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Product>().TableNoTracking
.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken);
if (ent == null)
throw new AppException("Product NotFound", ApiResultStatusCode.NotFound);
_repositoryWrapper.SetRepository<Product>().Delete(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,21 @@
namespace NetinaShop.Repository.Handlers.Products;
public class GetProductQueryHandler : IRequestHandler<GetProductQuery, ProductLDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetProductQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<ProductLDto> Handle(GetProductQuery request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Product>().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;
}
}

View File

@ -0,0 +1,19 @@
namespace NetinaShop.Repository.Handlers.Products;
public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, List<ProductSDto>>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public GetProductsQueryHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<ProductSDto>> Handle(GetProductsQuery request, CancellationToken cancellationToken)
{
return await _repositoryWrapper.SetRepository<Product>().TableNoTracking
.OrderByDescending(b => b.CreatedAt).Skip(request.Page * 10)
.Take(10)
.Select(ProductMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
}
}

View File

@ -0,0 +1,74 @@
namespace NetinaShop.Repository.Handlers.Products;
public class UpdateProductCommandHandler : IRequestHandler<UpdateProductCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public UpdateProductCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(UpdateProductCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Product>().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<Specification>().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<Specification>().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<ProductCategory>().TableNoTracking
.Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken);
foreach (var dbCat in dbCats)
{
if (request.Categories.Any(s => s == dbCat.CategoryId))
{
_repositoryWrapper.SetRepository<ProductCategory>().Delete(dbCat);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
}
foreach (var category in request.Categories)
{
if (dbCats.Any(c => c.Id == category))
newEnt.AddCategory(category);
}
var dbFiles = await _repositoryWrapper.SetRepository<ProductStorageFile>().TableNoTracking
.Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken);
foreach (var dbFile in dbFiles)
{
if (request.Files.Any(s => s.Id == dbFile.Id))
{
_repositoryWrapper.SetRepository<ProductStorageFile>().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<Product>().Update(newEnt);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,22 @@
using NetinaShop.Domain.Dtos.SmallDtos;
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.Warehouses;
public class CreateShippingCommandHandler : IRequestHandler<CreateShippingCommand , ShippingSDto>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public CreateShippingCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<ShippingSDto> Handle(CreateShippingCommand request, CancellationToken cancellationToken)
{
var ent = Shipping.Create(request.Title, request.WarehouseName, request.IsFastShipping, request.IsShipBySeller,
request.IsOriginalWarehouse);
_repositoryWrapper.SetRepository<Shipping>().Add(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.AdaptToSDto();
}
}

View File

@ -0,0 +1,24 @@
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.Warehouses;
public class DeleteShippingCommandHandler : IRequestHandler<DeleteShippingCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public DeleteShippingCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(DeleteShippingCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Shipping>().TableNoTracking
.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
if (ent == null)
throw new AppException("Shipping not found", ApiResultStatusCode.NotFound);
_repositoryWrapper.SetRepository<Shipping>().Delete(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -0,0 +1,27 @@
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Repository.Handlers.Warehouses;
public class UpdateShippingCommandHandler : IRequestHandler<UpdateShippingCommand, bool>
{
private readonly IRepositoryWrapper _repositoryWrapper;
public UpdateShippingCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
public async Task<bool> Handle(UpdateShippingCommand request, CancellationToken cancellationToken)
{
var ent = await _repositoryWrapper.SetRepository<Shipping>().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<Shipping>().Update(newEnt);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -28,9 +28,9 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Handlers\Categories\" />
<Folder Include="Models\" />
<Folder Include="Extensions\" />
<Folder Include="Repositories\Entity\Abstracts\" />
<Folder Include="Services\Abstracts\" />
</ItemGroup>
@ -41,6 +41,7 @@
<ItemGroup>
<Using Include="Mapster" />
<Using Include="MediatR" />
<Using Include="Microsoft.AspNetCore.Builder" />
<Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
@ -53,15 +54,27 @@
<Using Include="Microsoft.Extensions.Options" />
<Using Include="NetinaShop.Common.Extensions" />
<Using Include="NetinaShop.Common.Models" />
<Using Include="NetinaShop.Common.Models.Api" />
<Using Include="NetinaShop.Common.Models.Entity" />
<Using Include="NetinaShop.Common.Models.Exception" />
<Using Include="NetinaShop.Domain.CommandQueries.Commands" />
<Using Include="NetinaShop.Domain.CommandQueries.Queries" />
<Using Include="NetinaShop.Domain.Dtos.LargDtos" />
<Using Include="NetinaShop.Domain.Dtos.SmallDtos" />
<Using Include="NetinaShop.Domain.Entities.Categories" />
<Using Include="NetinaShop.Domain.Entities.Discounts" />
<Using Include="NetinaShop.Domain.Entities.Products" />
<Using Include="NetinaShop.Domain.Entities.Users" />
<Using Include="NetinaShop.Domain.Enums" />
<Using Include="NetinaShop.Domain.Mappers" />
<Using Include="NetinaShop.Domain.Models.Claims" />
<Using Include="NetinaShop.Domain.Models.Settings" />
<Using Include="NetinaShop.Repository.Abstracts" />
<Using Include="NetinaShop.Repository.Extensions" />
<Using Include="NetinaShop.Repository.Models" />
<Using Include="NetinaShop.Repository.Repositories.Base" />
<Using Include="NetinaShop.Repository.Repositories.Base.Contracts" />
<Using Include="NetinaShop.Repository.Repositories.Entity.Abstracts" />
<Using Include="NetinaShop.Repository.Services.Abstracts" />
<Using Include="Pluralize.NET" />
<Using Include="System.Diagnostics" />

View File

@ -11,7 +11,10 @@
public virtual async ValueTask<T> 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<T> 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<T> 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)

View File

@ -0,0 +1,5 @@
namespace NetinaShop.Repository.Repositories.Entity.Abstracts;
public interface IDiscountRepository : IScopedDependency, IDisposable, IReadRepository<Discount>, IWriteRepository<Discount>
{
}

View File

@ -0,0 +1,6 @@
namespace NetinaShop.Repository.Repositories.Entity.Abstracts;
public interface IProductRepository : IScopedDependency , IDisposable, IReadRepository<Product>, IWriteRepository<Product>
{
}

View File

@ -0,0 +1,12 @@
using NetinaShop.Repository.Repositories.Base;
using System.Threading;
namespace NetinaShop.Repository.Repositories.Entity;
public class DiscountRepository : BaseRepository<Discount>, IDiscountRepository
{
public DiscountRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService)
{
}
}

Some files were not shown because too many files have changed in this diff Show More