Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }