Example #1
0
        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)"Что то пошло не так. Попробуйте еще раз"));
            }
        }
Example #2
0
 public ActionResult ConfirmArbitrary(ArbitraryPaymentModel paymentInfo)
 {
     if (paymentInfo.AccountCardId == 0)
     {
         return(RedirectToAction("Arbitrary"));
     }
     return(View("ConfirmArbitrary", paymentInfo));
 }
Example #3
0
        public static void AddArbitraryOwnPayment(ArbitraryPaymentModel model, Repositories rep, int customerId)
        {
            OwnArbitraryPayment p = new OwnArbitraryPayment();

            p.BankCode         = model.BankName;
            p.CardAccountID    = model.AccountCardId;
            p.CustomerID       = customerId;
            p.Recipient        = model.Recipient;
            p.RecipientAccount = model.RecipientAccount;
            p.Target           = model.Target;
            p.UNP  = model.UNP;
            p.Name = "Произвольный платеж " + model.RecipientAccount;
            rep.OwnArbitraryPayments.Add(p);
            rep.SaveChanges();
        }
Example #4
0
        public static ArbitraryPaymentModel ArbitraryOwnPaymentToModel(int paymentId, Repositories rep)
        {
            OwnArbitraryPayment p = rep.OwnArbitraryPayments.GetSingle(paymentId);

            if (p == null)
            {
                return(null);
            }
            ArbitraryPaymentModel model = new ArbitraryPaymentModel();

            model.AccountCardId    = p.CardAccountID;
            model.BankName         = p.BankCode;
            model.Recipient        = p.Recipient;
            model.RecipientAccount = p.RecipientAccount;
            model.Target           = p.Target;
            model.UNP             = p.UNP;
            model.FromOwnPayments = true;
            return(model);
        }
Example #5
0
        public ActionResult Arbitrary(ArbitraryPaymentModel paymentInfo, FormCollection collection)
        {
            int cardId;

            if (!int.TryParse(collection["item.CardAccount.CardAccountID"], out cardId))
            {
                ModelState.Clear();
                ModelState.AddModelError("CustomError", "Карта не найдена");
                return(View(paymentInfo));
            }
            else if (ModelState.IsValid)
            {
                Customer customer = rep.Customers.GetSingle(WebSecurity.CurrentUserId);
                if (customer.IsLocked)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ваш аккаунт заблокирован");
                    return(View(paymentInfo));
                }
                paymentInfo.AccountCardId = cardId;
                CardAccount c = service.GetCardAccountById(cardId);
                if (c == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Карта не найдена");
                    return(View(paymentInfo));
                }
                paymentInfo.AccountCardNumber = CardAccountModule.ConvertCardNumberString(c.CardNumber);
                if (c.IsLocked)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ваша платежная карта заблокирована");
                    return(View(paymentInfo));
                }
                if (c.ExpiredDate < Time.GetTime())
                {
                    c.Status = "Истек срок действия";
                    service.UpdateCardAccount(c);
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Истек срок действия карты");
                    return(View(paymentInfo));
                }
                var bankAccount = service.GetBankAccountById(c.BankAccountID);
                if (bankAccount == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ошибка базы");
                    return(View(paymentInfo));
                }
                if (paymentInfo.Amount <= 0)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Сумма должна быть больше нуля");
                    return(View(paymentInfo));
                }
                if (!service.IsEnoughBalance(cardId, paymentInfo.Amount))
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Недостаточно средств на счете");
                    return(View(paymentInfo));
                }

                return(RedirectToAction("ConfirmArbitrary", paymentInfo));
            }
            else
            {
                return(View(paymentInfo));
            }
        }
Example #6
0
 public ActionResult Arbitrary(ArbitraryPaymentModel paymentInfo)
 {
     return(View(paymentInfo));
 }