public async Task <int> Handle(CreateFinancialInfoCommand request, CancellationToken cancellationToken) { var financialInformationCount = await _context.FinancialInformation .Where(f => f.CreatedBy == _currentUserService.UserId).CountAsync(cancellationToken); var financialInfo = new FinancialInfo { CardNumber = request.CardNumber, BankId = request.BankId == 0 ? null : request.BankId, AccountNumber = request.AccountNumber, Sheba = request.Sheba, BankCardImage = await _imageAccessor.Upload(request.BankCardImage, _currentUserService.UserId, "کارت بانکی " + ++financialInformationCount), Status = Status.Sent }; _context.FinancialInformation.Add(financialInfo); _notificationService.SendAsync(NotificationType.BankCard); await _context.SaveChangesAsync(cancellationToken); return(financialInfo.Id); }
public async Task <Unit> Handle(UpdateDocumentCommand request, CancellationToken cancellationToken) { var document = await _context.Documents.FindAsync(request.Id); if (document == null) { document = new Document { NationalCode = request.NationalCode, BirthDate = request.BirthDate }; if (request.NationalCardImage != null) { document.NationalCardImage = await _imageAccessor.Upload(request.NationalCardImage, _currentUserService.UserId, "نصویر کارت ملی"); document.NationalCardImageStatus = DocumentImagesStatus.Sent; _notificationService.SendAsync(NotificationType.NationalCard); } if (request.ApplicantImage != null) { document.ApplicantImage = await _imageAccessor.Upload(request.ApplicantImage, _currentUserService.UserId, "نصویر درخواست نامه"); document.ApplicantImageStatus = DocumentImagesStatus.Sent; _notificationService.SendAsync(NotificationType.Applicant); } _context.Documents.Add(document); } else { if (document.NationalCardImageStatus == DocumentImagesStatus.Rejected || document.NationalCardImageStatus == null) { document.NationalCode = request.NationalCode; document.BirthDate = request.BirthDate; if (request.NationalCardImage != null) { document.NationalCardImage = await _imageAccessor.Upload(request.NationalCardImage, _currentUserService.UserId, "تصویر کارت ملی"); document.NationalCardImageStatus = DocumentImagesStatus.Sent; _notificationService.SendAsync(NotificationType.NationalCard); } } if (document.ApplicantImageStatus == DocumentImagesStatus.Rejected || document.ApplicantImageStatus == null) { if (request.ApplicantImage != null) { document.ApplicantImage = await _imageAccessor.Upload(request.ApplicantImage, _currentUserService.UserId, "تصویر درخواست نامه"); document.ApplicantImageStatus = DocumentImagesStatus.Sent; _notificationService.SendAsync(NotificationType.Applicant); } } } await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }