public RoomsController( IGetAllRoomsQuery getAllRoomsQuery, ICreateRoomCommand createRoomCommand, IUpdateRoomCommand updateRoomCommand, IDeleteRoomCommand deleteRoomCommand) { this.getAllRoomsQuery = getAllRoomsQuery; this.createRoomCommand = createRoomCommand; this.updateRoomCommand = updateRoomCommand; this.deleteRoomCommand = deleteRoomCommand; }
public IActionResult Post([FromBody] CreateRoomModel newRoom, [FromServices] ICreateRoomCommand createRoomCommand) { if (ModelState.IsValid) { var storedRoom = createRoomCommand.Execute(newRoom); return(Created(Request.Path.Value + "/" + storedRoom.Id, storedRoom)); } else { return(BadRequest("Something went wrong")); } }
public IActionResult Post([FromBody] CreateRoomDto dto, [FromServices] ICreateRoomCommand createRoomCommand) { _dispatcher.DispatchCommand(createRoomCommand, dto); return(StatusCode(StatusCodes.Status201Created)); }