public async Task <TodoGetSingleResponse> PutTodo(int todoId, TodoPutRequest todo) { using (var connection = new SqlConnection(_connectionString)) { await connection.OpenAsync(); await connection.ExecuteAsync(@"EXEC dbo.Todo_Put @TodoId = @TodoId, @Title = @Title, @Description = @Description, @DateDeadline = @DateDeadline, @DateCompleted = @DateCompleted", new { TodoId = todoId, todo.Title, todo.Description, todo.DateDeadline, todo.DateCompleted } ); return(await GetTodo(todoId)); } }
public void Put(int id, [FromBody] TodoPutRequest request) { Todo.Toggle(id, request.Done); }
public async Task <ActionResult <TodoGetSingleResponse> > PutTodo(int todoId, TodoPutRequest todoPutRequest) { var todo = await _todoRepository.GetTodo(todoId); if (todo == null) { return(NotFound()); } todoPutRequest.Title = string.IsNullOrEmpty(todoPutRequest.Title) ? todo.Title : todoPutRequest.Title; todoPutRequest.Description = string.IsNullOrEmpty(todoPutRequest.Description) ? todo.Description : todoPutRequest.Description; todoPutRequest.DateDeadline = todoPutRequest.DateDeadline.HasValue ? todoPutRequest.DateDeadline : todo.DateDeadline; todoPutRequest.DateCompleted = todoPutRequest.DateCompleted.HasValue ? todoPutRequest.DateCompleted : todo.DateCompleted; var savedTodo = await _todoRepository.PutTodo(todoId, todoPutRequest); _cache.Remove(todoId); return(savedTodo); }