public async Task <bool> UpdateMessageInAsync(MessageIn sms) { if (sms != null) { _context.Update(sms); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task <bool> UpdateTaxPayerInAsync(TaxPayer taxpayer) { if (taxpayer != null) { _context.Update(taxpayer); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task <bool> UpdateEmailAsync(EmailLog emailLog) { if (emailLog != null) { _context.Update(emailLog); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task <bool> UpdateAuditLogAsync(AuditLog category) { if (category != null) { _context.Update(category); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task ProcessDeductions() { try { // get all deductions var deductions = await _context.TaxPayers.Where(x => x.IsActive == true && x.Balance > 0 && (DateTime.Compare(Convert.ToDateTime(x.NextPaymentDate), DateTime.Today) <= 0)) .ToListAsync(); //var newOnboard = await _context.MessageIns.Where(x => x.IsProcessed == false && x.msg.ToUpper() == "IPT").ToListAsync(); for (int i = 0; i < deductions.Count(); i++) { using (var transaction = await _context.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted)) { PaymentTransaction payment = new PaymentTransaction { PaymentDate = DateTime.Now, IPTaxId = deductions[i].IPTaxId, PaymentReferenceNo = _taxPayerRepository.GenerateTaxpayerIdAsync(10, false), AmountPaid = deductions[i].AmountToDeduct, PaymentType = deductions[i].SubscriptionType, PaymentServiceProvider = "SMS", TaxPayer = deductions[i], TransactionDate = DateTime.Now, TransactionReferenceNo = _taxPayerRepository.GuidToBigInteger(Guid.NewGuid()).ToString().Substring(0, 12), Status = "Success", CreatedBy = "Service", DateCreated = DateTime.Now }; DateTime nextpaymentDate = Convert.ToDateTime(deductions[i].NextPaymentDate); switch (deductions[i].SubscriptionType.ToUpper()) { case "DAILY": deductions[i].NextPaymentDate = nextpaymentDate.AddDays(1); deductions[i].TotalAmmountDeducted = deductions[i].TotalAmmountDeducted + 6; break; case "WEEKLY": deductions[i].NextPaymentDate = nextpaymentDate.AddDays(7); deductions[i].TotalAmmountDeducted = deductions[i].TotalAmmountDeducted + 42; break; case "MONTHLY": deductions[i].NextPaymentDate = nextpaymentDate.AddMonths(1); deductions[i].TotalAmmountDeducted = deductions[i].TotalAmmountDeducted + 168; break; default: break; } deductions[i].Balance = deductions[i].Balance - deductions[i].AmountToDeduct; var retSms = "Your " + deductions[i].SubscriptionType.ToUpper() + " IPT payment deductions of " + deductions[i].AmountToDeduct.ToString() + "NGN was successfull. Total Tax payable balance is " + deductions[i].Balance.ToString() + "NGN"; MessageOut messageOut = new MessageOut { MSGType = "SMS:TEXT", msg = retSms, PhoneNo = deductions[i].PhoneNo, ServiceType = "PAYMENT DEDUCTIONS", Sender = "I PAY TAX", Status = "Send", IsProcessed = true, Receiver = deductions[i].PhoneNo, DateProcessed = DateTime.Now }; deductions[i].LastPaymentDate = DateTime.Now; _context.Add(payment); _context.Update(deductions[i]); _context.Add(messageOut); _context.SaveChanges(); transaction.Commit(); // return; } } } catch (Exception ex) { throw; } }