public async Task EndUploadSessionAsync(EndUploadSessionCommand command) { // Load session Guid sessionId = new Guid(command.UploadSessionId); UploadSession session = await this.UploadSessionRepository.GetByIdAsync(sessionId); if (session == null) { //TODO: Throw exception: the specified upload session does not exist. throw new UploadSessionNotStartedException(string.Format("No upload session with the specified id ('{0}') has been previously started.", command.UploadSessionId)); } //TODO: Add the owner identifier to the command and ensure that it corresponds to the same person that started the upload session (authorization) // End session session.End(); // Save changes await this.UploadSessionRepository.SaveChangesAsync(); }
public async override Task EndUploadSessionAsync(EndUploadSessionCommand command) { this.Logger.LogInformation("[Start] {0} received.", command.GetType().Name); if (command != null) { this.Logger.LogInformation("[Start] Processing {0} with id = '{1}' and correlationId = '{2}'. Ending upload session.", command.GetType().Name, command.CommandId, command.CorrelationId); } await base.EndUploadSessionAsync(command); if (command != null) { this.Logger.LogInformation("[Finish] Processing {0} with id = '{1}' and correlationId = '{2}'. Ending upload session.", command.GetType().Name, command.CommandId, command.CorrelationId); } this.Logger.LogInformation("[Finish] {0} received.", command.GetType().Name); }
public async Task EndUploadSession_GivenValidArgsAndSessionStarted_DoesNotThrowException() { // Arrange string sessionId = "66339b0d-e3a1-4c7c-ae87-a52a10bb4bba"; EndUploadSessionCommand command = new EndUploadSessionCommand(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), new CommandIssuer(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()), sessionId); var applicationService = this.Fixture.Kernel.Get <IFileStorageCommandApplicationService>(); var uploadSessionRepository = this.Fixture.Kernel.Get <IUploadSessionRepository>(); // Act await applicationService.EndUploadSessionAsync(command); // Assert UploadSession session = await uploadSessionRepository.GetByIdAsync(new Guid(sessionId)); Assert.NotNull(session); Assert.Equal(sessionId, session.Id.ToString()); Assert.True(session.AreAllFilesUploaded); Assert.True(session.IsCompleted); }
public async virtual Task EndUploadSessionAsync(EndUploadSessionCommand command) { await this.ApplicationService.EndUploadSessionAsync(command); }
public async override Task EndUploadSessionAsync(EndUploadSessionCommand command) { await base.EndUploadSessionAsync(command); }