public async Task <ActionResult <ToDoListItem> > Post([FromBody] CreateUpdateToDoListItemRequest value) { try { var item = await repository.CreateToDoListItemAsync(value.Description); return(Ok(item)); } catch (Exception ex) { logger.LogError(ex, "An error occured while creating a new ToDoListItem: {0}", value); } return(StatusCode(StatusCodes.Status500InternalServerError)); }
public async Task <ActionResult> Put(int id, [FromBody] CreateUpdateToDoListItemRequest value) { try { await repository.UpdateToDoListItemDescriptionAsync(id, value.Description); return(Ok()); } catch (InvalidOperationException ex) { logger.LogInformation(ex, "ToDoListItem cannot found by id {0}", id); return(BadRequest()); } catch (Exception ex) { logger.LogError(ex, "An error occured while updating a ToDoListItem: {0} {1}", id, value); return(StatusCode(StatusCodes.Status500InternalServerError)); } }