public async Task <Unit> Handle(DeleteProjectCommand request, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var entity = await _queries.GetEntityAsync(request.Id.ToString(), request.Name, cancellationToken);

            await _repository.DeleteAsync(entity, cancellationToken);

            return(Unit.Value);
        }
Beispiel #2
0
        public async Task <Unit> Handle(DeleteTaskCommand request, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var existingTask = await _queries.GetEntityAsync(request.Id.ToString(), request.ProjectId.ToString(), cancellationToken);

            if (existingTask == null)
            {
                throw new DataNotFoundException(string.Format("Task with ID {0} not found.", request.Id));
            }

            await _repository.DeleteAsync(existingTask, cancellationToken);

            return(Unit.Value);
        }
Beispiel #3
0
        public async Task <ProjectViewModel> Handle(UpdateProjectCommand request, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var entity = await _queries.GetEntityAsync(request.Id.ToString(), request.Name, cancellationToken);

            if (entity == null)
            {
                entity = new ProjectEntity(Guid.NewGuid(), request.Name)
                {
                    Code = request.Code
                };
            }
            else
            {
                entity.Code = request.Code;
            }

            var updatedEntity = await _repository.UpdateOrInsertAsync(entity, cancellationToken);

            return(_mapper.Map <ProjectEntity, ProjectViewModel>(updatedEntity));
        }
Beispiel #4
0
        public async Task <TaskViewModel> Handle(UpdateTaskCommand request, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            await _projectService.ThrowIfProjectDoesNotExists(request.ProjectId);

            var existingTask = await _taskQueries.GetEntityAsync(request.Id.ToString(), request.ProjectId.ToString(), cancellationToken);

            existingTask.Name        = request.Name;
            existingTask.Description = existingTask.Description;

            var updatedTask = await _repository.UpdateOrInsertAsync(existingTask, cancellationToken);

            var viewModel = new TaskViewModel
            {
                Id          = Guid.Parse(updatedTask.RowKey),
                ProjectId   = Guid.Parse(updatedTask.PartitionKey),
                Name        = updatedTask.Name,
                Description = updatedTask.Description
            };

            return(viewModel);
        }