Api/NetinaShop.Domain/Mappers/ProductMapper.g.cs

734 lines
24 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),
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;
}
}
}