示例#1
0
        public async Task <bool> Handle(UpdateTaskInfoCommand request, CancellationToken cancellationToken)
        {
            var task = _TaskRepository.GetById(request.Id).Result.ToDomain <Task>(_Mapper);

            task.SetDescription(request.Description, request.LongDescription);

            var taskModel = task.ToModel <Command.Task>(_Mapper);

            await _TaskRepository.Update(taskModel);

            await _UnitOfWork.Commit();

            var busMessage = new Message();

            busMessage.MessageType = "AddUpdateTaskProject";
            busMessage.SetData(new
            {
                Project = task.Project.ToQueryModel <ProjectQuery.Project>(_Mapper),
                Task    = task.ToQueryModel <Query.Task>(_Mapper)
            });

            await _Bus.SendMessage(busMessage);

            return(true);
        }
示例#2
0
        public async Task <TaskDetailsDto> UpdateTaskInfo([FromRoute] int teamId,
                                                          [FromRoute] int taskId, [FromBody] JsonPatchDocument <TaskForUpdateDto> dto)
        {
            var command = new UpdateTaskInfoCommand
            {
                TaskForUpdateDto = new TaskForUpdateDto()
            };

            dto.ApplyTo(command.TaskForUpdateDto);
            command.TaskForUpdateDto.TaskId = taskId;

            return(await _mediator.Send(command));
        }
示例#3
0
        public void TaskCommandHandler_Handle_UpdateTaskInfoCommand_InvalidUpdateInfo_ThrowException(bool facebook, string description, string longDescription)
        {
            IRequestHandler <UpdateTaskInfoCommand, bool> handler = GetCommandHandlerInstance();
            var command = new UpdateTaskInfoCommand()
            {
                Id              = facebook ? FacebookTaskId : WindowsTaskId,
                Description     = description,
                LongDescription = longDescription
            };

            Action result = () => handler.Handle(command, default).Wait();

            result.Should().Throw <ValidationException>();
        }
示例#4
0
        public void TaskCommandHandler_Handle_UpdateTaskInfoCommand_InvalidTask_ThrowException()
        {
            IRequestHandler <UpdateTaskInfoCommand, bool> handler = GetCommandHandlerInstance();
            var command = new UpdateTaskInfoCommand()
            {
                Id              = Guid.NewGuid(),
                Description     = "Add new Feature #3435",
                LongDescription = "Implement it accordingly documentation"
            };

            Action result = () => handler.Handle(command, default).Wait();

            result.Should().Throw <ElementNotFoundException>();
        }
示例#5
0
        public void TaskCommandHandler_Handle_UpdateTaskInfoCommand_ValidUpdateInfo(bool facebook, string description, string longDescription)
        {
            IRequestHandler <UpdateTaskInfoCommand, bool> handler = GetCommandHandlerInstance();
            var command = new UpdateTaskInfoCommand()
            {
                Id              = facebook ? FacebookTaskId : WindowsTaskId,
                Description     = description,
                LongDescription = longDescription
            };

            var result = handler.Handle(command, default).Result;

            result.Should().BeTrue();
        }