public async Task <IActionResult> Post([FromBody] ToDoItem toDoItem) { try { _toDoItemBpc.InsertToDoItem(toDoItem); if (await _toDoItemBpc.SaveAllAsync()) { var uri = Url.Link("ToDoItemsByUser", new { userId = toDoItem.UserId }); return(Created(uri, toDoItem)); } else { _logger.LogWarning($"Could not save task in the database. itemId: {toDoItem.ToDoItemId}"); } } catch (Exception e) { _logger.LogError($"Something went wrong when saving the task. itemId: {toDoItem.ToDoItemId} - {e.Message}"); } return(BadRequest()); }
public void When_inserting_new_task_and_argument_is_null_throw_null_argument_exception() { Assert.Throws <ArgumentNullException>(() => _sut.InsertToDoItem(null)); }