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); }
public BrandDto(Brand brand) { this.Id = brand.Id; this.Name = brand.Name; }