예제 #1
0
 public ActionResult Edit(int id, [FromBody] PosterDto dto)
 {
     try
     {
         dto.Id = id;
         editPoster.Execute(dto);
         return(RedirectToAction(nameof(Index)));
     }
     catch (EntityNotAllowedException)
     {
         return(RedirectToAction("PageNotFound", "Redirections"));
     }
     catch (EntityAlreadyExistsException e)
     {
         TempData["error"] = e.Message;
     }
     catch (Exception e)
     {
         TempData["error"] = e.Message;
     }
     return(RedirectToAction(nameof(Index)));
 }
예제 #2
0
 public IActionResult Put(int id, [FromBody] PosterDto dto)
 {
     try
     {
         dto.Id = id;
         editPoster.Execute(dto);
         return(StatusCode(204));
     }
     catch (EntityAlreadyExistsException e)
     {
         return(StatusCode(409, new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
     catch (Exception e)
     {
         return(StatusCode(500, new
         {
             Errors = new List <string> {
                 e.Message
             }
         }));
     }
 }