public ActionResult Edit(int id, GetManufacturerDto dto)
 {
     if (!ModelState.IsValid)
     {
         return(View(dto));
     }
     try
     {
         // TODO: Add update logic here
         _editManufacturer.Execute(dto);
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityNotFoundException)
     {
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityAlreadyExistsException)
     {
         TempData["error"] = "Manufacturer with that name already exists, try a different one.";
         return(View(dto));
     }
     catch
     {
         return(RedirectToAction(nameof(Index)));
     }
 }
示例#2
0
 public IActionResult Put(int id, [FromBody] GetManufacturerDto dto)
 {
     try
     {
         dto.Id = id;
         _editManufacturerCommand.Execute(dto);
         return(StatusCode(204));
     }
     catch
     {
         return(StatusCode(422));
     }
 }