public async Task <ToDoListViewModel> Handle(GetToDoListQuery request, CancellationToken cancellationToken) { Logger.LogInformation($"Received request for To Do List by ID: '{request.Id}'"); var toDoList = await ToDoListRepository.Get(request.Id); if (toDoList == null) { throw new NotFoundException(request.Id, typeof(ToDoList)); } return(new ToDoListViewModel(toDoList)); }
public async Task <bool> Handle(DeleteToDoListCommand request, CancellationToken cancellationToken) { Logger.LogInformation($"Received request to delete ame To Do List {request.Id}"); var toDoList = await ToDoListRepository.Get(request.Id); if (toDoList == null) { throw new NotFoundException(request.Id, typeof(ToDoList)); } await ToDoListRepository.Delete(toDoList.Id); return(true); }
public async Task <ToDoListViewModel> Handle(UpdateToDoListDescriptionCommand request, CancellationToken cancellationToken) { Logger.LogInformation($"Received request to update description for To Do List {request.Id} to {request.Description}"); var toDoList = await ToDoListRepository.Get(request.Id); if (toDoList == null) { throw new NotFoundException(request.Id, typeof(ToDoList)); } toDoList.Description = request.Description; var response = await ToDoListRepository.Update(toDoList); return(new ToDoListViewModel(response)); }