public async Task <ActionResult> Update(UpdateProductRequestModel model)
        {
            var userId = this.User.GetId();

            var updated = await this.productService.Update(model.Id, userId, model.ModelName, model.Brand,
                                                           model.CategoryId, model.Description, model.CPUModel, model.RAM, model.StorageType,
                                                           model.Storage, model.Price, model.VideoCardModel, model.VideoCardMemory, model.ProductImageUrl,
                                                           model.OS, model.FrontCamera, model.BackCamera, model.Display, model.Weight, model.USB,
                                                           model.Ports, model.HDMI, model.Battery);

            if (!updated)
            {
                return(Unauthorized());
            }

            return(Ok());
        }
        public async Task <IActionResult> UpdateProduct([FromBody] UpdateProductRequestModel updateProductRequestModel)
        {
            var product = await GetProduct(updateProductRequestModel.Id);

            if (product == null)
            {
                return(NotFound());
            }

            product.Name       = updateProductRequestModel.Name;
            product.Image      = updateProductRequestModel.Image;
            product.Price      = updateProductRequestModel.Price;
            product.LastUpdate = DateTime.Now;

            var result = await _productRepository.UpdateAsync(filter => filter.Id == product.Id, product);

            return(result ? NoContent() : StatusCode(StatusCodes.Status500InternalServerError));
        }
        public async Task <Result> UpdateProductAsync(UpdateProductRequestModel model, Guid id)
        {
            var product = await All.FirstOrDefaultAsync(p => p.Id == id).ConfigureAwait(false);

            if (product == null)
            {
                return(NotFound);
            }

            product.Name        = model.Name;
            product.Description = model.Description;
            product.Price       = model.Price;
            product.Article     = model.Article;
            product.IsActive    = model.IsActive;
            product.IsVariable  = model.IsSingleAttribute;
            product.VideoUrl    = model.VideoUrl;
            product.CategoryId  = Guid.Parse(model.CategoryId);

            await Data.SaveChangesAsync().ConfigureAwait(false);

            return(Result.Success);
        }
 public async Task <ActionResult> Update(UpdateProductRequestModel model, Guid id)
 {
     return(await _products
            .UpdateProductAsync(model, id)
            .ToActionResult());
 }