private async Task <AssignPreviewImageResponse> AssignPreviewImageToTaskAsync(Guid taskId, Guid fileId) { var fileCreateCommand = new AssignPreviewImageCommand(taskId, fileId); var assignedPreviewImage = await this._commandDispatcher.Send(fileCreateCommand); return(assignedPreviewImage); }
public async Task <AssignPreviewImageResponse> Handle(AssignPreviewImageCommand request, CancellationToken cancellationToken) { var aggregate = this.AggregateRepository.GetById <TaskAggregateRoot>(request.TaskId); aggregate.AssignPreviewImage(request.FileId); await this.AggregateRepository.SaveAsync(aggregate); return(new AssignPreviewImageResponse(request.FileId)); }
public async Task Task_AssignPreviewImage_ReplacesImage() { // Arrange var commandDispatcher = this._testInfrastructure.DiContainer.GetInstance <IMediator>(); var newTask = await this.CreateNewTask(); var filePath = this._testInfrastructure.TestData.GetRandomImageFilePath(); var attachImageCommand = new AttachFileToTaskCommand(newTask.TaskId, filePath); var attachResult = await commandDispatcher.Send(attachImageCommand); var replacePrimaryImageCommand = new AssignPreviewImageCommand(newTask.TaskId, attachResult.FileId); await commandDispatcher.Send(replacePrimaryImageCommand); }