public ActionResult Create([FromForm] PosterDto dto) { if (!ModelState.IsValid) { TempData["error"] = "Something went wrong, check input and try again."; return(RedirectToAction(nameof(Create))); } try { addPoster.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))); }
public IActionResult Post([FromForm] PosterDto dto) { try { addPoster.Execute(dto); return(StatusCode(201)); } catch (Exception e) { return(StatusCode(500, new { Errors = new List <string> { e.Message } })); } }