public async Task <IActionResult> AddColor([FromBody] ColorViewModel colorVm)
        {
            var hasPermission = await _authorizationService.AuthorizeAsync(User, "COLOR", Operations.Create);

            if (hasPermission.Succeeded == false)
            {
                return(new BadRequestObjectResult(CommonConstants.Forbidden));
            }
            if (ModelState.IsValid)
            {
                _productQuantityService.AddColor(colorVm);
                _productQuantityService.SaveChanges();
                return(new OkObjectResult(colorVm.Id));
            }
            return(new BadRequestObjectResult(ModelState));
        }
 public HttpResponseMessage CreateColor(HttpRequestMessage request, ColorViewModel colorVm)
 {
     if (ModelState.IsValid)
     {
         var model = new Color();
         try
         {
             model.UpdateColor(colorVm);
             _productQuantityService.AddColor(model);
             _productQuantityService.Save();
             return(request.CreateResponse(HttpStatusCode.OK, colorVm));
         }
         catch (Exception dex)
         {
             return(request.CreateErrorResponse(HttpStatusCode.BadRequest, dex.Message));
         }
     }
     else
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
 }