public async Task <TodoModel> UpdateTodoAsync(TodoModel todoModel) { var todoEntity = new Data.Entities.Todo { Id = todoModel.Id, Description = todoModel.Description, IsCompleted = todoModel.IsCompleted, }; todoEntity = await _todoRepository.UpdateAsync(todoEntity); return(new TodoModel { Id = todoEntity.Id, Description = todoEntity.Description, IsCompleted = todoEntity.IsCompleted, }); }
public IAction ToggleTodo(Guid id) { return(new ThunkAction <AppState>(async(dispatch, getState) => { var todo = getState().Todos.Single(x => x.Id == id); var entity = new Data.Entities.Todo { Id = todo.Id, Text = todo.Text, IsCompleted = !todo.IsCompleted }; var updated = await _repo.UpdateTodo(entity); dispatch(new ToggleTodoAction { TodoId = id, IsCompleted = updated.IsCompleted }); })); }
public async Task <TodoModel> CreateTodoAsync(TodoModel todoModel) { if (todoModel is null) { throw new ArgumentNullException(nameof(todoModel)); } var todoEntity = new Data.Entities.Todo { Description = todoModel.Description, IsCompleted = todoModel.IsCompleted, }; todoEntity = await _todoRepository.AddAsync(todoEntity); return(new TodoModel { Id = todoEntity.Id, Description = todoEntity.Description, IsCompleted = todoEntity.IsCompleted, }); }