405 lines
13 KiB
C#
405 lines
13 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.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;
|
|
|
|
}
|
|
}
|
|
} |