public IActionResult Post([FromQuery] CreateTopicDto dto) { try { _addCommand.Execute(dto); return(NoContent()); } catch (EntityAlreadyExistsException) { return(NotFound()); } catch (Exception) { return(StatusCode(500, "An error ocurred")); } }
public ActionResult Create(CreateTopicDto dto) { if (!ModelState.IsValid) { return(View(dto)); } try { _addCommand.Execute(dto); return(RedirectToAction(nameof(Index))); } catch (EntityAlreadyExistsException) { TempData["error"] = "with the same name already exists"; } catch (Exception) { TempData["error"] = "An error occured"; } return(View()); }