Ejemplo n.º 1
0
 public async Task <IActionResult> CreateBrand(BrandDto brandDto)
 {
     if (await _brandService.CheckBrandExists(brandDto.Brand_ID))
     {
         return(BadRequest("Brand ID already exists !"));
     }
     if (await _brandService.Add(brandDto))
     {
         return(CreatedAtRoute("GetBrand", new { }));
     }
     throw new Exception("Create the brand is failed.");
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateBrand(BrandDto brandDto)
        {
            if (await _brandService.CheckBrandExists(brandDto.Brand_ID))
            {
                return(BadRequest("Brand ID already exists!"));
            }
            var username = User.FindFirst(ClaimTypes.Name).Value;

            brandDto.Updated_By = username;
            if (await _brandService.Add(brandDto))
            {
                return(CreatedAtRoute("GetBrands", new { }));
            }

            throw new Exception("Creating the brand failed on save");
        }