Пример #1
0
 public IActionResult Post([FromForm] CreateMovieDTO dto)
 {
     try
     {
         createMovie.Execute(dto);
         return(StatusCode(201));
     }catch (EntityNotFoundException e)
     {
         return(UnprocessableEntity(e.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
Пример #2
0
 public IActionResult Post([FromBody] MovieDto obj)
 {
     try
     {
         _createMovie.Execute(obj);
         return(StatusCode(201));
     }
     catch (EntityAlreadyExistException)
     {
         return(Conflict());
     }
     catch
     {
         return(StatusCode(500));
     }
 }
Пример #3
0
        public ActionResult Create(CreateMovieDTO request)
        {
            if (!ModelState.IsValid)
            {
                TempData["greska"] = "Greska pri unosu";
                RedirectToAction("create");
            }

            try
            {
                createMovie.Execute(request);

                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityAlreadyExist e)
            {
                TempData["error"] = e.Message;
            }
            catch (Exception e)
            {
                TempData["error"] = e.Message;
            }
            return(View());
        }