public async Task <IActionResult> CreateNew(int user, [FromBody] WhiteboardDtoIn boardDto) { var owner = await _userService.GetById(user); if (owner == null) { return(BadRequest("Could not find User associated to the Owner field")); } var board = new Whiteboard() { Id = boardDto.Id, Title = boardDto.Title, User = owner }; try { await _boardService.Create(board); return(CreatedAtAction(nameof(GetById), new { id = boardDto.Id }, boardDto)); } catch (WhiteboardException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task <IActionResult> Update(int id, [FromBody] WhiteboardDtoIn boardIn) { var board = _mapper.Map <Whiteboard>(boardIn); try { await _boardService.Update(board); return(Ok()); } catch (WhiteboardException ex) { return(BadRequest(new { message = ex.Message })); } }