public async Task <IActionResult> PostStatusAsync([FromBody] Status status) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var _id = await statusService.CreateStatusAsync(status); return(Ok()); }
public Task <HttpResponseMessage> Post(StatusViewModel model) { var request = new CreateStatusRequest { Status = _Mapper.Map <Status>(model) }; return(_StatusService.CreateStatusAsync(request).ContinueWith(resp => { var message = resp.Result; var viewModel = _Mapper.Map <StatusViewModel>(message.Status); return _ResponseMapper.ForCreate(Request, viewModel, message.Result); })); }
public void CreateStatusAsync_WhenCalled_ReturnsCreatedObject() { _context .Setup(c => c.AddAsync(_newStatus)) .Returns(async() => { return(await Task.Run(() => { return _newStatus; })); }); var result = _statusService.CreateStatusAsync(_newStatus); _context.Verify(c => c.AddAsync(_newStatus), Times.Once); }