public async Task <IActionResult> UpdateAsync(Guid id, [FromBody] EmployeeDomainModel model) { if (model == null || model.EmployeeId != id) { return(BadRequest("The model that is passed in is empty. Model object is required.")); } EmployeeDomainModel selected; try { selected = await _domain.GetAsync(id).ConfigureAwait(false); if (selected == null) { return(NotFound("The asset category selected to be updated could not be found.")); } } catch (Exception ex) { return(BadRequest(ex.InnerException)); } selected.FirstName = model.FirstName; selected.LastName = model.LastName; selected.ModifiedDate = DateTime.UtcNow; try { await _domain.UpdateAsync(selected).ConfigureAwait(false); } catch (Exception ex) { return(BadRequest(ex.InnerException)); } return(Ok(selected)); }
public void UpdateAsync_WithNullEmployeeParameter_ReturnArgumentNullException() { Func <Task> act = () => _domain.UpdateAsync(null); act.Should().Throw <ArgumentNullException>(); }