284 lines
9.8 KiB
C#
284 lines
9.8 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.ProductCategories;
|
|
|
|
namespace NetinaShop.Domain.Mappers
|
|
{
|
|
public static partial class CategoryMapper
|
|
{
|
|
public static ProductCategory AdaptToCategory(this ProductCategoryLDto p1)
|
|
{
|
|
return p1 == null ? null : new ProductCategory()
|
|
{
|
|
Name = p1.Name,
|
|
Description = p1.Description,
|
|
ParentId = (Guid?)p1.ParentId,
|
|
Files = funcMain1(p1.Files),
|
|
Id = p1.Id
|
|
};
|
|
}
|
|
public static ProductCategory AdaptTo(this ProductCategoryLDto p3, ProductCategory p4)
|
|
{
|
|
if (p3 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ProductCategory result = p4 ?? new ProductCategory();
|
|
|
|
result.Name = p3.Name;
|
|
result.Description = p3.Description;
|
|
result.ParentId = (Guid?)p3.ParentId;
|
|
result.Files = funcMain2(p3.Files, result.Files);
|
|
result.Id = p3.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ProductCategoryLDto, ProductCategory>> ProjectToCategory => p7 => new ProductCategory()
|
|
{
|
|
Name = p7.Name,
|
|
Description = p7.Description,
|
|
ParentId = (Guid?)p7.ParentId,
|
|
Files = p7.Files.Select<StorageFileSDto, ProductCategoryStorageFile>(p8 => new ProductCategoryStorageFile()
|
|
{
|
|
Name = p8.Name,
|
|
FileLocation = p8.FileLocation,
|
|
FileName = p8.FileName,
|
|
IsHeader = p8.IsHeader,
|
|
IsPrimary = p8.IsPrimary,
|
|
FileType = p8.FileType,
|
|
Id = p8.Id
|
|
}).ToList<ProductCategoryStorageFile>(),
|
|
Id = p7.Id
|
|
};
|
|
public static ProductCategoryLDto AdaptToLDto(this ProductCategory p9)
|
|
{
|
|
return p9 == null ? null : new ProductCategoryLDto()
|
|
{
|
|
Name = p9.Name,
|
|
Description = p9.Description,
|
|
ParentId = p9.ParentId == null ? default(Guid) : (Guid)p9.ParentId,
|
|
Files = funcMain3(p9.Files),
|
|
Id = p9.Id
|
|
};
|
|
}
|
|
public static ProductCategoryLDto AdaptTo(this ProductCategory p11, ProductCategoryLDto p12)
|
|
{
|
|
if (p11 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ProductCategoryLDto result = p12 ?? new ProductCategoryLDto();
|
|
|
|
result.Name = p11.Name;
|
|
result.Description = p11.Description;
|
|
result.ParentId = p11.ParentId == null ? default(Guid) : (Guid)p11.ParentId;
|
|
result.Files = funcMain4(p11.Files, result.Files);
|
|
result.Id = p11.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ProductCategory, ProductCategoryLDto>> ProjectToLDto => p15 => new ProductCategoryLDto()
|
|
{
|
|
Name = p15.Name,
|
|
Description = p15.Description,
|
|
ParentId = p15.ParentId == null ? default(Guid) : (Guid)p15.ParentId,
|
|
Files = p15.Files.Select<ProductCategoryStorageFile, 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 ProductCategory AdaptToCategory(this ProductCategorySDto p17)
|
|
{
|
|
return p17 == null ? null : new ProductCategory()
|
|
{
|
|
Name = p17.Name,
|
|
Description = p17.Description,
|
|
IsMain = p17.IsMain,
|
|
ParentId = (Guid?)p17.ParentId,
|
|
Id = p17.Id
|
|
};
|
|
}
|
|
public static ProductCategory AdaptTo(this ProductCategorySDto p18, ProductCategory p19)
|
|
{
|
|
if (p18 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ProductCategory result = p19 ?? new ProductCategory();
|
|
|
|
result.Name = p18.Name;
|
|
result.Description = p18.Description;
|
|
result.IsMain = p18.IsMain;
|
|
result.ParentId = (Guid?)p18.ParentId;
|
|
result.Id = p18.Id;
|
|
return result;
|
|
|
|
}
|
|
public static ProductCategorySDto AdaptToSDto(this ProductCategory p20)
|
|
{
|
|
return p20 == null ? null : new ProductCategorySDto()
|
|
{
|
|
Name = p20.Name,
|
|
Description = p20.Description,
|
|
IsMain = p20.IsMain,
|
|
ParentId = p20.ParentId == null ? default(Guid) : (Guid)p20.ParentId,
|
|
Id = p20.Id
|
|
};
|
|
}
|
|
public static ProductCategorySDto AdaptTo(this ProductCategory p21, ProductCategorySDto p22)
|
|
{
|
|
if (p21 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ProductCategorySDto result = p22 ?? new ProductCategorySDto();
|
|
|
|
result.Name = p21.Name;
|
|
result.Description = p21.Description;
|
|
result.IsMain = p21.IsMain;
|
|
result.ParentId = p21.ParentId == null ? default(Guid) : (Guid)p21.ParentId;
|
|
result.Id = p21.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ProductCategory, ProductCategorySDto>> ProjectToSDto => p23 => new ProductCategorySDto()
|
|
{
|
|
Name = p23.Name,
|
|
Description = p23.Description,
|
|
IsMain = p23.IsMain,
|
|
ParentId = p23.ParentId == null ? default(Guid) : (Guid)p23.ParentId,
|
|
Id = p23.Id
|
|
};
|
|
|
|
private static List<ProductCategoryStorageFile> funcMain1(List<StorageFileSDto> p2)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ProductCategoryStorageFile> result = new List<ProductCategoryStorageFile>(p2.Count);
|
|
|
|
int i = 0;
|
|
int len = p2.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
StorageFileSDto item = p2[i];
|
|
result.Add(item == null ? null : new ProductCategoryStorageFile()
|
|
{
|
|
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<ProductCategoryStorageFile> funcMain2(List<StorageFileSDto> p5, List<ProductCategoryStorageFile> p6)
|
|
{
|
|
if (p5 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ProductCategoryStorageFile> result = new List<ProductCategoryStorageFile>(p5.Count);
|
|
|
|
int i = 0;
|
|
int len = p5.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
StorageFileSDto item = p5[i];
|
|
result.Add(item == null ? null : new ProductCategoryStorageFile()
|
|
{
|
|
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<ProductCategoryStorageFile> p10)
|
|
{
|
|
if (p10 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<StorageFileSDto> result = new List<StorageFileSDto>(p10.Count);
|
|
|
|
int i = 0;
|
|
int len = p10.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ProductCategoryStorageFile 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<ProductCategoryStorageFile> 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)
|
|
{
|
|
ProductCategoryStorageFile 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;
|
|
|
|
}
|
|
}
|
|
} |