public void Setup() { _command = new DeleteAppealFileCommand { ApplicationId = _applicationId, FileName = _fileName, UserId = "userId", UserName = "******" }; var upload = new AppealFile { Id = _appealUploadId, FileName = _fileName, ApplicationId = _applicationId }; _appealUploadRepository = new Mock <IAppealFileRepository>(); _appealUploadRepository.Setup(x => x.Get(_applicationId, _fileName)).ReturnsAsync(upload); _appealUploadRepository.Setup(x => x.Get(_appealUploadId)).ReturnsAsync(upload); _appealUploadRepository.Setup(x => x.Remove(It.IsAny <Guid>())); _auditService = new Mock <IAuditService>(); _auditService.Setup(x => x.StartTracking(UserAction.RemoveAppealFile, _command.UserId, _command.UserName)); _auditService.Setup(x => x.AuditDelete(It.IsAny <AppealFile>())); _handler = new DeleteAppealFileCommandHandler(_appealUploadRepository.Object, _auditService.Object); }
public async Task PersistAdd(AppealFile entity) { var transaction = _unitOfWork.GetTransaction(); await transaction.Connection.ExecuteAsync( @"INSERT INTO [AppealFile] ([Id], [ApplicationId], [FileName], [ContentType], [Size], [UserId], [UserName], [CreatedOn]) VALUES ( @Id, @ApplicationId, @FileName, @ContentType, @Size, @UserId, @UserName, @CreatedOn)", entity, transaction); }
public async Task Run_Downloads_and_Saves_Appeal_File_Into_BlobStorage() { var appealfile = new AppealFile { ApplicationId = _applicationId, FileName = "file.pdf" }; var request = new AppealFileExtractRequest(appealfile); await _sut.Run(request); _applyApiClient.Verify(x => x.DownloadAppealFile(_applicationId, appealfile.FileName), Times.Once); _blobClient.Verify(x => x.UploadAsync(It.IsAny <Stream>(), true, It.IsAny <CancellationToken>()), Times.Once); }
public async Task PersistUpdate(AppealFile entity) { var transaction = _unitOfWork.GetTransaction(); await transaction.Connection.ExecuteAsync( @"UPDATE [AppealFile] SET [FileName] = @FileName, [ContentType] = @ContentType, [Size] = @Size, [UserId] = @UserId, [UserName] = @UserName, [CreatedOn] = @CreatedOn WHERE [Id] = @id", entity, transaction); }
public void Setup() { _appealsQueries = new Mock <IAppealsQueries>(); _appealFile = new AppealFile { FileName = _fileName, ContentType = _contentType, ApplicationId = _applicationId, Id = _appealFileId }; _appealsQueries.Setup(x => x.GetAppealFile(_applicationId, _fileName)).ReturnsAsync(_appealFile); _handler = new GetAppealFileQueryHandler(_appealsQueries.Object); }
public APIResult AppealFileSave(AppealFile appealFile) { try { appealService.AppealFileSave(appealFile); return(new APIResult() { Status = true, Body = "" }); } catch (Exception ex) { return(new APIResult() { Status = false, Body = ex.Message.ToString() }); } }
public async Task Handle_Records_Uploaded_File_When_Existing() { var existingFile = new AppealFile { ApplicationId = _command.ApplicationId, FileName = _command.AppealFile.FileName }; _appealUploadRepository.Setup(x => x.Get(_command.ApplicationId, _command.AppealFile.FileName)).ReturnsAsync(existingFile); await _handler.Handle(_command, CancellationToken.None); _appealUploadRepository.Verify(x => x.Update(It.Is <AppealFile>(upload => upload.ApplicationId == _command.ApplicationId && upload.FileName == _command.AppealFile.FileName && upload.ContentType == _command.AppealFile.ContentType && upload.UserId == _command.UserId && upload.UserName == _command.UserName && upload.Size == _command.AppealFile.Data.Length ))); _auditService.Verify(x => x.Save()); }
/// <summary> /// /// </summary> /// <param name="appealFile"></param> public void AppealFileSave(AppealFile appealFile) { if (appealFile.SeqNO == 0) { AppealFile findOneMax = db.AppealFile.Where(x => (x.AppealId == appealFile.AppealId)).OrderByDescending(x => x.SeqNO).FirstOrDefault(); if (findOneMax == null) { appealFile.SeqNO = 1; } else { appealFile.SeqNO = findOneMax.SeqNO + 1; } appealFile.InDateTime = DateTime.Now; db.AppealFile.Add(appealFile); } else { } db.SaveChanges(); }
public async Task <Unit> Handle(UploadAppealFileCommand request, CancellationToken cancellationToken) { _auditService.StartTracking(UserAction.UploadAppealFile, request.UserId, request.UserName); var appealFile = await _appealFileRepository.Get(request.ApplicationId, request.AppealFile.FileName); if (appealFile is null) { appealFile = new AppealFile { ApplicationId = request.ApplicationId, ContentType = request.AppealFile.ContentType, FileName = request.AppealFile.FileName, Size = request.AppealFile.Data.Length, UserId = request.UserId, UserName = request.UserName }; _auditService.AuditInsert(appealFile); _appealFileRepository.Add(appealFile); } else { _auditService.AuditUpdate(appealFile); appealFile.ContentType = request.AppealFile.ContentType; appealFile.Size = request.AppealFile.Data.Length; appealFile.UserId = request.UserId; appealFile.UserName = request.UserName; appealFile.CreatedOn = DateTime.UtcNow; _appealFileRepository.Update(appealFile); } _auditService.Save(); return(await Task.FromResult(Unit.Value)); }
public AppealFileExtractRequest(AppealFile appealFile) { ApplicationId = appealFile.ApplicationId; FileName = appealFile.FileName; }
public void Update(AppealFile entity) { _unitOfWork.Register(() => PersistUpdate(entity)); }
public void Add(AppealFile entity) { _unitOfWork.Register(() => PersistAdd(entity)); }