Ejemplo n.º 1
0
 public IActionResult Post([FromQuery] CreateTopicDto dto)
 {
     try
     {
         _addCommand.Execute(dto);
         return(NoContent());
     }
     catch (EntityAlreadyExistsException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error ocurred"));
     }
 }
Ejemplo n.º 2
0
        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());
        }