public async Task <Unit> Handle(SetTaskDoneCommand request, CancellationToken cancellationToken) { // first find if any tasks exists with the id var task = await _context.Set <LTask>() .FindAsync(request.Id); if (task == null) { throw new NotFoundException("Task", request.Id); } task.IsDone = true; _context.Set <LTask>().Update(task); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public async Task <TaskListViewModel> Handle(GetAllTasksQuery request, CancellationToken cancellationToken) { return(new TaskListViewModel { Tasks = await _context.Set <LTask>() .ProjectTo <TaskLookupModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <UserListViewModel> Handle(GetUserssListQuery request, CancellationToken cancellationToken) { return(new UserListViewModel { Users = await _context .Set <AppUser>() .Where(u => !u.IsAdmin) .ProjectTo <UserLookupModel>(_mapper.ConfigurationProvider) .ToListAsync(cancellationToken) }); }
public async Task <Unit> Handle(CreateTaskCommand request, CancellationToken cancellationToken) { var task = new LTask { TaskName = request.Name, TaskDescription = request.Description, IsDone = false }; await _context.Set <LTask>().AddAsync(task, cancellationToken); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }