public PaymentAccountsModel EditPaymentsAccounts(long PAID) { ShomaRMEntities db = new ShomaRMEntities(); PaymentAccountsModel model = new PaymentAccountsModel(); var editPaymentAccounts = db.tbl_PaymentAccounts.Where(co => co.PAID == PAID).FirstOrDefault(); string decryptedCardNumber = string.IsNullOrWhiteSpace(editPaymentAccounts.CardNumber) ? "" : new EncryptDecrypt().DecryptText(editPaymentAccounts.CardNumber); string decryptedAccountNumber = string.IsNullOrWhiteSpace(editPaymentAccounts.AccountNumber) ? "" : new EncryptDecrypt().DecryptText(editPaymentAccounts.AccountNumber); string decrytpedCardMonth = string.IsNullOrWhiteSpace(editPaymentAccounts.Month) ? "" : new EncryptDecrypt().DecryptText(editPaymentAccounts.Month); string decrytpedCardYear = string.IsNullOrWhiteSpace(editPaymentAccounts.Year) ? "" : new EncryptDecrypt().DecryptText(editPaymentAccounts.Year); string decrytpedRoutingNumber = string.IsNullOrWhiteSpace(editPaymentAccounts.RoutingNumber)? "" : new EncryptDecrypt().DecryptText(editPaymentAccounts.RoutingNumber); if (editPaymentAccounts != null) { model.PAID = editPaymentAccounts.PAID; model.TenantId = editPaymentAccounts.TenantId; model.AccountName = editPaymentAccounts.AccountName; model.NameOnCard = editPaymentAccounts.NameOnCard; model.CardNumber = decryptedCardNumber; model.Month = decrytpedCardMonth; model.Year = decrytpedCardYear; model.CardType = editPaymentAccounts.CardType; model.PayMethod = editPaymentAccounts.PayMethod; model.BankName = editPaymentAccounts.BankName; model.AccountNumber = decryptedAccountNumber; model.RoutingNumber = decrytpedRoutingNumber; } return(model); }
public string SaveUpdatePaymentsAccounts(PaymentAccountsModel model) { string msg = ""; ShomaRMEntities db = new ShomaRMEntities(); string encrytpedCardNumber = model.CardNumber == null? "" : new EncryptDecrypt().EncryptText(model.CardNumber); string encrytpedAccountNumber = model.AccountNumber == null ? "" : new EncryptDecrypt().EncryptText(model.AccountNumber); string encrytpedCardMonth = new EncryptDecrypt().EncryptText(model.Month); string encrytpedCardYear = new EncryptDecrypt().EncryptText(model.Year); string encrytpedRoutingNumber = model.RoutingNumber == null? "" : new EncryptDecrypt().EncryptText(model.RoutingNumber); if (model.PAID == 0) { var savePaymentAccounts = new tbl_PaymentAccounts() { TenantId = model.TenantId, NameOnCard = model.NameOnCard, CardNumber = encrytpedCardNumber, Month = encrytpedCardMonth, Year = encrytpedCardYear, CardType = model.CardType, PayMethod = model.PayMethod, BankName = model.BankName, AccountName = model.AccountName, AccountNumber = encrytpedAccountNumber, RoutingNumber = encrytpedRoutingNumber }; db.tbl_PaymentAccounts.Add(savePaymentAccounts); db.SaveChanges(); msg = "Payment Account Saved Successfully"; } else { var updatePaymentAccounts = db.tbl_PaymentAccounts.Where(co => co.PAID == model.PAID).FirstOrDefault(); if (updatePaymentAccounts != null) { updatePaymentAccounts.TenantId = model.TenantId; if (model.PayMethod == 1) { updatePaymentAccounts.AccountName = model.AccountName; updatePaymentAccounts.NameOnCard = model.NameOnCard; updatePaymentAccounts.CardNumber = encrytpedCardNumber; updatePaymentAccounts.Month = encrytpedCardMonth; updatePaymentAccounts.Year = encrytpedCardYear; updatePaymentAccounts.CardType = model.CardType; updatePaymentAccounts.PayMethod = model.PayMethod; updatePaymentAccounts.BankName = ""; updatePaymentAccounts.AccountNumber = ""; updatePaymentAccounts.RoutingNumber = ""; } else if (model.PayMethod == 2) { updatePaymentAccounts.NameOnCard = ""; updatePaymentAccounts.CardNumber = ""; updatePaymentAccounts.Month = ""; updatePaymentAccounts.Year = ""; updatePaymentAccounts.CardType = 0; updatePaymentAccounts.PayMethod = model.PayMethod; updatePaymentAccounts.BankName = model.BankName; updatePaymentAccounts.AccountName = model.AccountName; updatePaymentAccounts.AccountNumber = encrytpedAccountNumber; updatePaymentAccounts.RoutingNumber = encrytpedRoutingNumber; } db.SaveChanges(); } msg = "Progress Update Successfully"; } db.Dispose(); return(msg); }