public CommandResult Update(string id, ProductUpdateCommand command)
        {
            if (id != command.Id)
            {
                return(new CommandResult(false, "Id inválido. ", null));
            }

            var result = _handler.Update(command);

            return(result);
        }
Beispiel #2
0
        public ActionResult UpdateProductPost(Product product)
        {
            try {
                List <KeyValuePair <string, string> > errors = productValidator.CanUpdateProduct(product);
                if (errors.Count == 0)
                {
                    bool result = productHandler.Update(product);
                    if (result)
                    {
                        return(RedirectToAction("GetProductList"));
                    }
                    else
                    {
                        this.ModelState.AddModelError("", "Something got wrong when update product. Product not updated!");
                        return(View("UpdateProduct", product));

                        ;
                    }
                }
                else
                {
                    foreach (KeyValuePair <string, string> error in errors)
                    {
                        this.ModelState.AddModelError(error.Key, error.Value);
                    }
                    return(View("UpdateProduct", product));
                }
            }
            catch (Exception ex) {
                this.ModelState.AddModelError("", ex.Message);
                if (ex.InnerException != null)
                {
                    this.ModelState.AddModelError("", ex.InnerException.Message);
                }
                return(View("UpdateProduct", product));
            }
        }
Beispiel #3
0
 public async Task Update(Product product)
 {
     await Task.Run(() => {
         _productHandler.Update(product);
     });
 }
Beispiel #4
0
        public async Task <ActionResult <MovieDto> > ModifiyMovie(int id, MovieDto movie)
        {
            var result = await handler.Update(id, movie);

            return(Ok(result));
        }