public async Task <IHttpActionResult> Post(string boardSlug, BoardColumn boardColumn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await mediator.Send(new CreateBoardColumnCommand { BoardSlug = boardSlug, BoardColumn = boardColumn }); if (result == null) { return(NotFound()); } hyperMediaFactory.Apply(result); return(Created(hyperMediaFactory.GetLink(result, Link.SELF), result)); } catch (CreateBoardColumnCommandSlugExistsException) { return(Conflict()); } catch (BoardNotFoundException) { return(NotFound()); } }
public async Task <IHttpActionResult> Post(string boardSlug, BoardTask boardTask) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await commandDispatcher.HandleAsync <CreateBoardTaskCommand, BoardTask>(new CreateBoardTaskCommand { BoardSlug = boardSlug, BoardTask = boardTask }); hyperMediaFactory.Apply(result); return(Created(hyperMediaFactory.GetLink(result, Link.SELF), result)); } catch (BoardColumnNotFoundException) { return(BadRequest("Board Column Not Found")); } catch (BoardNotFoundException) { return(NotFound()); } }
public async Task <IHttpActionResult> Post(Board board) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await mediator.Send( new CreateBoardCommand { Board = board }); hyperMediaFactory.Apply(result); return(Created(hyperMediaFactory.GetLink(result, Link.SELF), result)); } catch (CreateBoardCommandSlugExistsException) { return(Conflict()); } }