Exemple #1
0
        public static ProductTypeDto ToDto(this DataAccess.Models.ProductType item)
        {
            ProductTypeDto dto = null;

            if (item != null)
            {
                dto = new ProductTypeDto
                {
                    Id         = item.Id,
                    Name       = item.Name,
                    Brands     = item.Brand == null ? null : item.Brand.ToBasicDto() as List <BrandDto>,
                    Categories = item.Category != null?item.Category.ToBasicDto() as List <CategoryDto> : null
                };
            }

            return(dto);
        }
Exemple #2
0
        public static ProductTypeDto ToAdminDto(this DataAccess.Models.ProductType item)
        {
            ProductTypeDto dto = null;

            if (item != null)
            {
                dto = new ProductTypeDto
                {
                    Id         = item.Id,
                    Name       = item.Name,
                    Brands     = new List <BrandDto>(),
                    Categories = new List <CategoryDto>()
                };

                item.Brand.ToList().ForEach(b => dto.Brands.Add(new BrandDto {
                    Id = b.Id, Name = b.Name
                }));
                item.Category.ToList().ForEach(c => dto.Categories.Add(new CategoryDto {
                    Id = c.Id, Name = c.Name
                }));
            }

            return(dto);
        }