public async Task <IActionResult> Put([FromBody] Product model, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != model.Id)
            {
                return(BadRequest());
            }
            try
            {
                _productRepositry.Update(model);
            }
            catch (DbUpdateConcurrencyException)
            {
                //if (!ShopeExists(id))
                //{
                //    return NotFound();
                //}
                //else
                //{
                //    throw;
                //}
            }

            return(NoContent());
        }
Example #2
0
        public ActionResult Edit(Product product)
        {
            if (ModelState.IsValid)
            {
                productService.Update(product);
                return(RedirectToAction("Index"));
            }
            var viewModel = new UserProductViewModel
            {
                Product    = product,
                Categories = categoryService.GetAll()
            };

            return(View(viewModel));
        }