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); }
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)); }
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>(); }
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>(); }
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(); }