452 lines
15 KiB
C#
452 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using Netina.Domain.Dtos.LargDtos;
|
|
using Netina.Domain.Dtos.SmallDtos;
|
|
using Netina.Domain.Entities.Brands;
|
|
|
|
namespace Netina.Domain.Mappers
|
|
{
|
|
public static partial class BrandMapper
|
|
{
|
|
public static Brand AdaptToBrand(this BrandLDto p1)
|
|
{
|
|
return p1 == null ? null : new Brand()
|
|
{
|
|
PersianName = p1.PersianName,
|
|
EnglishName = p1.EnglishName,
|
|
Slug = p1.Slug,
|
|
Description = p1.Description,
|
|
HasSpecialPage = p1.HasSpecialPage,
|
|
PageUrl = p1.PageUrl,
|
|
Files = funcMain1(p1.Files),
|
|
MetaTags = funcMain2(p1.MetaTags),
|
|
Id = p1.Id,
|
|
CreatedAt = p1.CreatedAt
|
|
};
|
|
}
|
|
public static Brand AdaptTo(this BrandLDto p4, Brand p5)
|
|
{
|
|
if (p4 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Brand result = p5 ?? new Brand();
|
|
|
|
result.PersianName = p4.PersianName;
|
|
result.EnglishName = p4.EnglishName;
|
|
result.Slug = p4.Slug;
|
|
result.Description = p4.Description;
|
|
result.HasSpecialPage = p4.HasSpecialPage;
|
|
result.PageUrl = p4.PageUrl;
|
|
result.Files = funcMain3(p4.Files, result.Files);
|
|
result.MetaTags = funcMain4(p4.MetaTags, result.MetaTags);
|
|
result.Id = p4.Id;
|
|
result.CreatedAt = p4.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<BrandLDto, Brand>> ProjectToBrand => p10 => new Brand()
|
|
{
|
|
PersianName = p10.PersianName,
|
|
EnglishName = p10.EnglishName,
|
|
Slug = p10.Slug,
|
|
Description = p10.Description,
|
|
HasSpecialPage = p10.HasSpecialPage,
|
|
PageUrl = p10.PageUrl,
|
|
Files = p10.Files.Select<StorageFileSDto, BrandStorageFile>(p11 => new BrandStorageFile()
|
|
{
|
|
Name = p11.Name,
|
|
FileLocation = p11.FileLocation,
|
|
FileName = p11.FileName,
|
|
IsHeader = p11.IsHeader,
|
|
IsPrimary = p11.IsPrimary,
|
|
FileType = p11.FileType,
|
|
Id = p11.Id,
|
|
CreatedAt = p11.CreatedAt
|
|
}).ToList<BrandStorageFile>(),
|
|
MetaTags = p10.MetaTags.Select<MetaTagSDto, BrandMetaTag>(p12 => new BrandMetaTag()
|
|
{
|
|
Type = p12.Type,
|
|
Value = p12.Value,
|
|
Id = p12.Id,
|
|
CreatedAt = p12.CreatedAt
|
|
}).ToList<BrandMetaTag>(),
|
|
Id = p10.Id,
|
|
CreatedAt = p10.CreatedAt
|
|
};
|
|
public static BrandLDto AdaptToLDto(this Brand p13)
|
|
{
|
|
return p13 == null ? null : new BrandLDto()
|
|
{
|
|
PersianName = p13.PersianName,
|
|
EnglishName = p13.EnglishName,
|
|
Description = p13.Description,
|
|
HasSpecialPage = p13.HasSpecialPage,
|
|
Slug = p13.Slug,
|
|
PageUrl = p13.PageUrl,
|
|
Files = funcMain5(p13.Files),
|
|
MetaTags = funcMain6(p13.MetaTags),
|
|
Id = p13.Id,
|
|
CreatedAt = p13.CreatedAt
|
|
};
|
|
}
|
|
public static BrandLDto AdaptTo(this Brand p16, BrandLDto p17)
|
|
{
|
|
if (p16 == null)
|
|
{
|
|
return null;
|
|
}
|
|
BrandLDto result = p17 ?? new BrandLDto();
|
|
|
|
result.PersianName = p16.PersianName;
|
|
result.EnglishName = p16.EnglishName;
|
|
result.Description = p16.Description;
|
|
result.HasSpecialPage = p16.HasSpecialPage;
|
|
result.Slug = p16.Slug;
|
|
result.PageUrl = p16.PageUrl;
|
|
result.Files = funcMain7(p16.Files, result.Files);
|
|
result.MetaTags = funcMain8(p16.MetaTags, result.MetaTags);
|
|
result.Id = p16.Id;
|
|
result.CreatedAt = p16.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Brand, BrandLDto>> ProjectToLDto => p22 => new BrandLDto()
|
|
{
|
|
PersianName = p22.PersianName,
|
|
EnglishName = p22.EnglishName,
|
|
Description = p22.Description,
|
|
HasSpecialPage = p22.HasSpecialPage,
|
|
Slug = p22.Slug,
|
|
PageUrl = p22.PageUrl,
|
|
Files = p22.Files.Select<BrandStorageFile, StorageFileSDto>(p23 => new StorageFileSDto()
|
|
{
|
|
Name = p23.Name,
|
|
FileLocation = p23.FileLocation,
|
|
FileName = p23.FileName,
|
|
IsHeader = p23.IsHeader,
|
|
IsPrimary = p23.IsPrimary,
|
|
FileType = p23.FileType,
|
|
Id = p23.Id
|
|
}).ToList<StorageFileSDto>(),
|
|
MetaTags = p22.MetaTags.Select<BrandMetaTag, MetaTagSDto>(p24 => new MetaTagSDto()
|
|
{
|
|
Type = p24.Type,
|
|
Value = p24.Value,
|
|
Id = p24.Id,
|
|
CreatedAt = p24.CreatedAt
|
|
}).ToList<MetaTagSDto>(),
|
|
Id = p22.Id,
|
|
CreatedAt = p22.CreatedAt
|
|
};
|
|
public static Brand AdaptToBrand(this BrandSDto p25)
|
|
{
|
|
return p25 == null ? null : new Brand()
|
|
{
|
|
PersianName = p25.PersianName,
|
|
EnglishName = p25.EnglishName,
|
|
Slug = p25.Slug,
|
|
Description = p25.Description,
|
|
HasSpecialPage = p25.HasSpecialPage,
|
|
PageUrl = p25.PageUrl,
|
|
Id = p25.Id,
|
|
CreatedAt = p25.CreatedAt
|
|
};
|
|
}
|
|
public static Brand AdaptTo(this BrandSDto p26, Brand p27)
|
|
{
|
|
if (p26 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Brand result = p27 ?? new Brand();
|
|
|
|
result.PersianName = p26.PersianName;
|
|
result.EnglishName = p26.EnglishName;
|
|
result.Slug = p26.Slug;
|
|
result.Description = p26.Description;
|
|
result.HasSpecialPage = p26.HasSpecialPage;
|
|
result.PageUrl = p26.PageUrl;
|
|
result.Id = p26.Id;
|
|
result.CreatedAt = p26.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static BrandSDto AdaptToSDto(this Brand p28)
|
|
{
|
|
return p28 == null ? null : new BrandSDto()
|
|
{
|
|
PersianName = p28.PersianName,
|
|
EnglishName = p28.EnglishName,
|
|
Description = p28.Description,
|
|
Slug = p28.Slug,
|
|
HasSpecialPage = p28.HasSpecialPage,
|
|
PageUrl = p28.PageUrl,
|
|
Id = p28.Id,
|
|
CreatedAt = p28.CreatedAt
|
|
};
|
|
}
|
|
public static BrandSDto AdaptTo(this Brand p29, BrandSDto p30)
|
|
{
|
|
if (p29 == null)
|
|
{
|
|
return null;
|
|
}
|
|
BrandSDto result = p30 ?? new BrandSDto();
|
|
|
|
result.PersianName = p29.PersianName;
|
|
result.EnglishName = p29.EnglishName;
|
|
result.Description = p29.Description;
|
|
result.Slug = p29.Slug;
|
|
result.HasSpecialPage = p29.HasSpecialPage;
|
|
result.PageUrl = p29.PageUrl;
|
|
result.Id = p29.Id;
|
|
result.CreatedAt = p29.CreatedAt;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Brand, BrandSDto>> ProjectToSDto => p31 => new BrandSDto()
|
|
{
|
|
PersianName = p31.PersianName,
|
|
EnglishName = p31.EnglishName,
|
|
Description = p31.Description,
|
|
Slug = p31.Slug,
|
|
HasSpecialPage = p31.HasSpecialPage,
|
|
PageUrl = p31.PageUrl,
|
|
Id = p31.Id,
|
|
CreatedAt = p31.CreatedAt
|
|
};
|
|
|
|
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,
|
|
CreatedAt = item.CreatedAt
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<BrandMetaTag> funcMain2(List<MetaTagSDto> p3)
|
|
{
|
|
if (p3 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<BrandMetaTag> result = new List<BrandMetaTag>(p3.Count);
|
|
|
|
int i = 0;
|
|
int len = p3.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
MetaTagSDto item = p3[i];
|
|
result.Add(item == null ? null : new BrandMetaTag()
|
|
{
|
|
Type = item.Type,
|
|
Value = item.Value,
|
|
Id = item.Id,
|
|
CreatedAt = item.CreatedAt
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<BrandStorageFile> funcMain3(List<StorageFileSDto> p6, List<BrandStorageFile> p7)
|
|
{
|
|
if (p6 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<BrandStorageFile> result = new List<BrandStorageFile>(p6.Count);
|
|
|
|
int i = 0;
|
|
int len = p6.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
StorageFileSDto item = p6[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,
|
|
CreatedAt = item.CreatedAt
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<BrandMetaTag> funcMain4(List<MetaTagSDto> p8, List<BrandMetaTag> p9)
|
|
{
|
|
if (p8 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<BrandMetaTag> result = new List<BrandMetaTag>(p8.Count);
|
|
|
|
int i = 0;
|
|
int len = p8.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
MetaTagSDto item = p8[i];
|
|
result.Add(item == null ? null : new BrandMetaTag()
|
|
{
|
|
Type = item.Type,
|
|
Value = item.Value,
|
|
Id = item.Id,
|
|
CreatedAt = item.CreatedAt
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<StorageFileSDto> funcMain5(List<BrandStorageFile> p14)
|
|
{
|
|
if (p14 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<StorageFileSDto> result = new List<StorageFileSDto>(p14.Count);
|
|
|
|
int i = 0;
|
|
int len = p14.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
BrandStorageFile item = p14[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<MetaTagSDto> funcMain6(List<BrandMetaTag> p15)
|
|
{
|
|
if (p15 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<MetaTagSDto> result = new List<MetaTagSDto>(p15.Count);
|
|
|
|
int i = 0;
|
|
int len = p15.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
BrandMetaTag item = p15[i];
|
|
result.Add(item == null ? null : new MetaTagSDto()
|
|
{
|
|
Type = item.Type,
|
|
Value = item.Value,
|
|
Id = item.Id,
|
|
CreatedAt = item.CreatedAt
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<StorageFileSDto> funcMain7(List<BrandStorageFile> p18, List<StorageFileSDto> p19)
|
|
{
|
|
if (p18 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<StorageFileSDto> result = new List<StorageFileSDto>(p18.Count);
|
|
|
|
int i = 0;
|
|
int len = p18.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
BrandStorageFile item = p18[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<MetaTagSDto> funcMain8(List<BrandMetaTag> p20, List<MetaTagSDto> p21)
|
|
{
|
|
if (p20 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<MetaTagSDto> result = new List<MetaTagSDto>(p20.Count);
|
|
|
|
int i = 0;
|
|
int len = p20.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
BrandMetaTag item = p20[i];
|
|
result.Add(item == null ? null : new MetaTagSDto()
|
|
{
|
|
Type = item.Type,
|
|
Value = item.Value,
|
|
Id = item.Id,
|
|
CreatedAt = item.CreatedAt
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |