public async Task <IActionResult> CreateBrand(BrandForCreationDto brandForCreationDto) { brandForCreationDto.Name = brandForCreationDto.Name.ToLower(); var brand = new Brand { Name = brandForCreationDto.Name }; if (await _repo.BrandExists(brand)) { return(BadRequest(string.Format("There is already a brand with name: {0}", brand.Name.ToLower()))); } _repo.Add(brand); await _repo.SaveAll(); return(Ok(brand)); }
private bool BrandExists(int id) { return(_repository.BrandExists(id)); }