コード例 #1
0
        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));
        }
コード例 #2
0
 private bool BrandExists(int id)
 {
     return(_repository.BrandExists(id));
 }