public IActionResult Put([FromBody] ProductDto productDto)
 {
     if (productDto == null)
     {
         return(BadRequest(ModelState));
     }
     _productApplicationService.UpdateProduct(productDto);
     return(Ok());
 }
Пример #2
0
        public ActionResult EditProduct(Product updatedProduct, FormCollection formCollection)
        {
            try
            {
                _productApplicationService.UpdateProduct(updatedProduct);

                var certificationMarks = formCollection.GetValues("CertificationMarks") ?? new string[] {};
                _productApplicationService.RemoveAllCertificationMarksFromProduct(updatedProduct.Id);
                foreach (var certificationMark in certificationMarks)
                {
                    int certificationMarkId;
                    if (int.TryParse(certificationMark, out certificationMarkId))
                    {
                        _productApplicationService.AddCertificationMarkToProduct(updatedProduct.Id, int.Parse(certificationMark));
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }