Пример #1
0
        public BrandDto Add(BrandRequestDto dto)
        {
            var brand = new Brand();

            if (dto.Id != 0)
            {
                brand = uow.Brands.GetAll().Where(x => x.Id == dto.Id)
                    .Single();
                brand.Name = dto.Name;

            } else
            {
                brand = new Brand() { Name = dto.Name };
                this.uow.Brands.Add(brand);
            }

            this.uow.SaveChanges();
            return new BrandDto(brand);
        }
Пример #2
0
 public BrandDto(Brand brand)
 {
     this.Id = brand.Id;
     this.Name = brand.Name;
 }