651 lines
22 KiB
C#
651 lines
22 KiB
C#
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),
|
|
Files = funcMain3(p1.Files),
|
|
Id = p1.Id
|
|
};
|
|
}
|
|
public static Product AdaptTo(this ProductLDto p5, Product p6)
|
|
{
|
|
if (p5 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Product result = p6 ?? new Product();
|
|
|
|
result.PersianName = p5.PersianName;
|
|
result.EnglishName = p5.EnglishName;
|
|
result.Summery = p5.Summery;
|
|
result.ExpertCheck = p5.ExpertCheck;
|
|
result.Tags = p5.Tags;
|
|
result.Warranty = p5.Warranty;
|
|
result.BrandId = p5.BrandId;
|
|
result.Specifications = funcMain4(p5.Specifications, result.Specifications);
|
|
result.Reviews = funcMain5(p5.Reviews, result.Reviews);
|
|
result.Files = funcMain6(p5.Files, result.Files);
|
|
result.Id = p5.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ProductLDto, Product>> ProjectToProduct => p13 => new Product()
|
|
{
|
|
PersianName = p13.PersianName,
|
|
EnglishName = p13.EnglishName,
|
|
Summery = p13.Summery,
|
|
ExpertCheck = p13.ExpertCheck,
|
|
Tags = p13.Tags,
|
|
Warranty = p13.Warranty,
|
|
BrandId = p13.BrandId,
|
|
Specifications = p13.Specifications.Select<SpecificationSDto, Specification>(p14 => new Specification()
|
|
{
|
|
Title = p14.Title,
|
|
Detail = p14.Detail,
|
|
Value = p14.Value,
|
|
IsFeature = p14.IsFeature,
|
|
ProductId = p14.ProductId,
|
|
ParentId = p14.ParentId,
|
|
Id = p14.Id
|
|
}).ToList<Specification>(),
|
|
Reviews = p13.Reviews.Select<ReviewSDto, Review>(p15 => new Review()
|
|
{
|
|
Title = p15.Title,
|
|
Comment = p15.Comment,
|
|
Rate = p15.Rate,
|
|
IsBuyer = p15.IsBuyer,
|
|
ProductId = p15.ProductId,
|
|
UserId = p15.UserId,
|
|
Id = p15.Id
|
|
}).ToList<Review>(),
|
|
Files = p13.Files.Select<StorageFileSDto, ProductStorageFile>(p16 => new ProductStorageFile()
|
|
{
|
|
Name = p16.Name,
|
|
FileLocation = p16.FileLocation,
|
|
FileName = p16.FileName,
|
|
IsHeader = p16.IsHeader,
|
|
IsPrimary = p16.IsPrimary,
|
|
FileType = p16.FileType,
|
|
Id = p16.Id
|
|
}).ToList<ProductStorageFile>(),
|
|
Id = p13.Id
|
|
};
|
|
public static ProductLDto AdaptToLDto(this Product p17)
|
|
{
|
|
return p17 == null ? null : new ProductLDto()
|
|
{
|
|
PersianName = p17.PersianName,
|
|
EnglishName = p17.EnglishName,
|
|
Summery = p17.Summery,
|
|
ExpertCheck = p17.ExpertCheck,
|
|
Tags = p17.Tags,
|
|
Warranty = p17.Warranty,
|
|
BrandId = p17.BrandId,
|
|
Specifications = funcMain7(p17.Specifications),
|
|
Reviews = funcMain8(p17.Reviews),
|
|
Files = funcMain9(p17.Files),
|
|
Id = p17.Id
|
|
};
|
|
}
|
|
public static ProductLDto AdaptTo(this Product p21, ProductLDto p22)
|
|
{
|
|
if (p21 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ProductLDto result = p22 ?? new ProductLDto();
|
|
|
|
result.PersianName = p21.PersianName;
|
|
result.EnglishName = p21.EnglishName;
|
|
result.Summery = p21.Summery;
|
|
result.ExpertCheck = p21.ExpertCheck;
|
|
result.Tags = p21.Tags;
|
|
result.Warranty = p21.Warranty;
|
|
result.BrandId = p21.BrandId;
|
|
result.Specifications = funcMain10(p21.Specifications, result.Specifications);
|
|
result.Reviews = funcMain11(p21.Reviews, result.Reviews);
|
|
result.Files = funcMain12(p21.Files, result.Files);
|
|
result.Id = p21.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Product, ProductLDto>> ProjectToLDto => p29 => new ProductLDto()
|
|
{
|
|
PersianName = p29.PersianName,
|
|
EnglishName = p29.EnglishName,
|
|
Summery = p29.Summery,
|
|
ExpertCheck = p29.ExpertCheck,
|
|
Tags = p29.Tags,
|
|
Warranty = p29.Warranty,
|
|
BrandId = p29.BrandId,
|
|
Specifications = p29.Specifications.Select<Specification, SpecificationSDto>(p30 => new SpecificationSDto()
|
|
{
|
|
Title = p30.Title,
|
|
Detail = p30.Detail,
|
|
Value = p30.Value,
|
|
IsFeature = p30.IsFeature,
|
|
ProductId = p30.ProductId,
|
|
ParentId = p30.ParentId,
|
|
Id = p30.Id
|
|
}).ToList<SpecificationSDto>(),
|
|
Reviews = p29.Reviews.Select<Review, ReviewSDto>(p31 => new ReviewSDto()
|
|
{
|
|
Title = p31.Title,
|
|
Comment = p31.Comment,
|
|
Rate = p31.Rate,
|
|
IsBuyer = p31.IsBuyer,
|
|
ProductId = p31.ProductId,
|
|
UserId = p31.UserId,
|
|
Id = p31.Id
|
|
}).ToList<ReviewSDto>(),
|
|
Files = p29.Files.Select<ProductStorageFile, StorageFileSDto>(p32 => new StorageFileSDto()
|
|
{
|
|
Name = p32.Name,
|
|
FileLocation = p32.FileLocation,
|
|
FileName = p32.FileName,
|
|
IsHeader = p32.IsHeader,
|
|
IsPrimary = p32.IsPrimary,
|
|
FileType = p32.FileType,
|
|
Id = p32.Id
|
|
}).ToList<StorageFileSDto>(),
|
|
Id = p29.Id
|
|
};
|
|
public static Product AdaptToProduct(this ProductSDto p33)
|
|
{
|
|
return p33 == null ? null : new Product()
|
|
{
|
|
PersianName = p33.PersianName,
|
|
EnglishName = p33.EnglishName,
|
|
Summery = p33.Summery,
|
|
ExpertCheck = p33.ExpertCheck,
|
|
Tags = p33.Tags,
|
|
Warranty = p33.Warranty,
|
|
Cost = p33.Cost,
|
|
IsEnable = p33.IsEnable,
|
|
BeDisplayed = p33.BeDisplayed,
|
|
PackingCost = p33.PackingCost,
|
|
Rate = p33.Rate,
|
|
ReviewCount = p33.ReviewCount,
|
|
Viewed = p33.Viewed,
|
|
BrandId = p33.BrandId,
|
|
CategoryId = p33.CategoryId,
|
|
Id = p33.Id
|
|
};
|
|
}
|
|
public static Product AdaptTo(this ProductSDto p34, Product p35)
|
|
{
|
|
if (p34 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Product result = p35 ?? new Product();
|
|
|
|
result.PersianName = p34.PersianName;
|
|
result.EnglishName = p34.EnglishName;
|
|
result.Summery = p34.Summery;
|
|
result.ExpertCheck = p34.ExpertCheck;
|
|
result.Tags = p34.Tags;
|
|
result.Warranty = p34.Warranty;
|
|
result.Cost = p34.Cost;
|
|
result.IsEnable = p34.IsEnable;
|
|
result.BeDisplayed = p34.BeDisplayed;
|
|
result.PackingCost = p34.PackingCost;
|
|
result.Rate = p34.Rate;
|
|
result.ReviewCount = p34.ReviewCount;
|
|
result.Viewed = p34.Viewed;
|
|
result.BrandId = p34.BrandId;
|
|
result.CategoryId = p34.CategoryId;
|
|
result.Id = p34.Id;
|
|
return result;
|
|
|
|
}
|
|
public static ProductSDto AdaptToSDto(this Product p36)
|
|
{
|
|
return p36 == null ? null : new ProductSDto()
|
|
{
|
|
PersianName = p36.PersianName,
|
|
EnglishName = p36.EnglishName,
|
|
Summery = p36.Summery,
|
|
ExpertCheck = p36.ExpertCheck,
|
|
Tags = p36.Tags,
|
|
Warranty = p36.Warranty,
|
|
Cost = p36.Cost,
|
|
IsEnable = p36.IsEnable,
|
|
BeDisplayed = p36.BeDisplayed,
|
|
PackingCost = p36.PackingCost,
|
|
Rate = p36.Rate,
|
|
ReviewCount = p36.ReviewCount,
|
|
Viewed = p36.Viewed,
|
|
CategoryId = p36.CategoryId,
|
|
BrandId = p36.BrandId,
|
|
Id = p36.Id
|
|
};
|
|
}
|
|
public static ProductSDto AdaptTo(this Product p37, ProductSDto p38)
|
|
{
|
|
if (p37 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ProductSDto result = p38 ?? new ProductSDto();
|
|
|
|
result.PersianName = p37.PersianName;
|
|
result.EnglishName = p37.EnglishName;
|
|
result.Summery = p37.Summery;
|
|
result.ExpertCheck = p37.ExpertCheck;
|
|
result.Tags = p37.Tags;
|
|
result.Warranty = p37.Warranty;
|
|
result.Cost = p37.Cost;
|
|
result.IsEnable = p37.IsEnable;
|
|
result.BeDisplayed = p37.BeDisplayed;
|
|
result.PackingCost = p37.PackingCost;
|
|
result.Rate = p37.Rate;
|
|
result.ReviewCount = p37.ReviewCount;
|
|
result.Viewed = p37.Viewed;
|
|
result.CategoryId = p37.CategoryId;
|
|
result.BrandId = p37.BrandId;
|
|
result.Id = p37.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Product, ProductSDto>> ProjectToSDto => p39 => new ProductSDto()
|
|
{
|
|
PersianName = p39.PersianName,
|
|
EnglishName = p39.EnglishName,
|
|
Summery = p39.Summery,
|
|
ExpertCheck = p39.ExpertCheck,
|
|
Tags = p39.Tags,
|
|
Warranty = p39.Warranty,
|
|
Cost = p39.Cost,
|
|
IsEnable = p39.IsEnable,
|
|
BeDisplayed = p39.BeDisplayed,
|
|
PackingCost = p39.PackingCost,
|
|
Rate = p39.Rate,
|
|
ReviewCount = p39.ReviewCount,
|
|
Viewed = p39.Viewed,
|
|
CategoryId = p39.CategoryId,
|
|
BrandId = p39.BrandId,
|
|
Id = p39.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<ProductStorageFile> funcMain3(List<StorageFileSDto> p4)
|
|
{
|
|
if (p4 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ProductStorageFile> result = new List<ProductStorageFile>(p4.Count);
|
|
|
|
int i = 0;
|
|
int len = p4.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
StorageFileSDto item = p4[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> funcMain4(List<SpecificationSDto> p7, List<Specification> p8)
|
|
{
|
|
if (p7 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<Specification> result = new List<Specification>(p7.Count);
|
|
|
|
int i = 0;
|
|
int len = p7.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
SpecificationSDto item = p7[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> funcMain5(List<ReviewSDto> p9, List<Review> p10)
|
|
{
|
|
if (p9 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<Review> result = new List<Review>(p9.Count);
|
|
|
|
int i = 0;
|
|
int len = p9.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ReviewSDto item = p9[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<ProductStorageFile> funcMain6(List<StorageFileSDto> p11, List<ProductStorageFile> p12)
|
|
{
|
|
if (p11 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ProductStorageFile> result = new List<ProductStorageFile>(p11.Count);
|
|
|
|
int i = 0;
|
|
int len = p11.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
StorageFileSDto item = p11[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> funcMain7(List<Specification> p18)
|
|
{
|
|
if (p18 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<SpecificationSDto> result = new List<SpecificationSDto>(p18.Count);
|
|
|
|
int i = 0;
|
|
int len = p18.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
Specification item = p18[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> funcMain8(List<Review> p19)
|
|
{
|
|
if (p19 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ReviewSDto> result = new List<ReviewSDto>(p19.Count);
|
|
|
|
int i = 0;
|
|
int len = p19.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
Review item = p19[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<StorageFileSDto> funcMain9(List<ProductStorageFile> p20)
|
|
{
|
|
if (p20 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<StorageFileSDto> result = new List<StorageFileSDto>(p20.Count);
|
|
|
|
int i = 0;
|
|
int len = p20.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ProductStorageFile 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;
|
|
|
|
}
|
|
|
|
private static List<SpecificationSDto> funcMain10(List<Specification> p23, List<SpecificationSDto> p24)
|
|
{
|
|
if (p23 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<SpecificationSDto> result = new List<SpecificationSDto>(p23.Count);
|
|
|
|
int i = 0;
|
|
int len = p23.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
Specification item = p23[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> funcMain11(List<Review> p25, List<ReviewSDto> p26)
|
|
{
|
|
if (p25 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ReviewSDto> result = new List<ReviewSDto>(p25.Count);
|
|
|
|
int i = 0;
|
|
int len = p25.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
Review item = p25[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<StorageFileSDto> funcMain12(List<ProductStorageFile> p27, List<StorageFileSDto> p28)
|
|
{
|
|
if (p27 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<StorageFileSDto> result = new List<StorageFileSDto>(p27.Count);
|
|
|
|
int i = 0;
|
|
int len = p27.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ProductStorageFile item = p27[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;
|
|
|
|
}
|
|
}
|
|
} |