public ActionResult ConfirmArbitrary(ArbitraryPaymentModel paymentInfo, FormCollection collcetion) { if (paymentInfo.AccountCardId == 0) { return(RedirectToAction("Arbitrary")); } if (paymentInfo.ToOwnPayments) { OwnPaymentsModule.AddArbitraryOwnPayment(paymentInfo, rep, WebSecurity.CurrentUserId); } ArbitraryTransaction tr = new ArbitraryTransaction(); tr.Amount = paymentInfo.Amount; tr.BankCode = paymentInfo.BankName; tr.CardAccountID = paymentInfo.AccountCardId; tr.CustomerID = WebSecurity.CurrentUserId; tr.Recipient = paymentInfo.Recipient; tr.RecipientAccount = paymentInfo.RecipientAccount; tr.Target = paymentInfo.Target; tr.UNP = paymentInfo.UNP; bool success = service.CreateArbitraryTransaction(tr); if (success) { return(View("Message", (object)"Ваш платеж успешно завершен")); } else { return(View("Message", (object)"Что то пошло не так. Попробуйте еще раз")); } }
public void RemoveArbitraryTransaction(ArbitraryTransaction arbitraryTransaction) { using (Repositories rep = new Repositories()) { rep.ArbitraryTransactions.Remove(arbitraryTransaction); rep.SaveChanges(); } }
public bool CreateArbitraryTransaction(ArbitraryTransaction arbitraryTransaction) { try { using (Repositories rep = new Repositories()) { CardAccount card = rep.CardAccounts.GetSingle(arbitraryTransaction.CardAccountID); BankAccount acc = rep.BankAccounts.GetSingle(card.BankAccountID); BankAccount bank = null; switch (acc.CurrencyID) { case 1: bank = rep.BankAccounts.GetAll(a => a.AcountNumber == "1111111111111111").FirstOrDefault(); break; case 2: bank = rep.BankAccounts.GetAll(a => a.AcountNumber == "1111111111111112").FirstOrDefault(); break; case 3: bank = rep.BankAccounts.GetAll(a => a.AcountNumber == "1111111111111113").FirstOrDefault(); break; case 4: bank = rep.BankAccounts.GetAll(a => a.AcountNumber == "1111111111111114").FirstOrDefault(); break; } if (arbitraryTransaction.Amount > acc.Balance) { return(false); } if (card.IsLocked) { return(false); } if (card.ExpiredDate < Time.GetTime()) { return(false); } arbitraryTransaction.Date = Time.GetTime(); acc.Balance -= arbitraryTransaction.Amount; bank.Balance += arbitraryTransaction.Amount; rep.BankAccounts.Update(acc); rep.BankAccounts.Update(bank); rep.ArbitraryTransactions.Add(arbitraryTransaction); rep.SaveChanges(); } } catch (Exception ex) { return(false); } return(true); }