public IActionResult Put(int id, [FromForm] EditMovieDTO dto) { try { var movie = baza.Movies.Find(id); if (movie == null) { return(NotFound()); } editMovie.Execute(dto); return(NoContent()); } catch (EntityNotFoundException e) { return(UnprocessableEntity(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult Put(int id, [FromBody] MovieDto dto) { try { dto.Id = id; editMovie.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 } })); } }
public ActionResult Edit(int id, EditMovieDTO request) { if (!ModelState.IsValid) { TempData["greska"] = "Greska pri unosu"; RedirectToAction("create"); } try { editMovie.Execute(request); return(RedirectToAction(nameof(Index))); } catch (EntityNotFoundException e) { TempData["greska"] = e.Message; } catch (Exception e) { TempData["greska"] = e.Message; } return(View()); }