Example #1
0
        public ActionResult HistoryList(FormCollection collection)
        {
            var id   = collection["id"];
            var type = collection["type"];

            if (id == null || type == null)
            {
                return(RedirectToAction("Index"));
            }

            RouteValueDictionary RouteValues = new RouteValueDictionary();

            RouteValues.Add("item.CardAccount.CardAccountID", collection["item.CardAccount.CardAccountID"]);
            RouteValues.Add("datepicker-from", collection["datepicker-from"]);
            RouteValues.Add("datepicker-to", collection["datepicker-to"]);
            RouteValues.Add("arbitrary_payments", collection["arbitrary_payments"]);
            RouteValues.Add("ssisp_payments", collection["ssisp_payments"]);
            RouteValues.Add("mobile_payments", collection["mobile_payments"]);
            RouteValues.Add("transfer_payments", collection["transfer_payments"]);

            if (type == PaymentType.Mobile.ToString())
            {
                var mobileTransaction = service.GetMobileTransactionById(Int32.Parse(id));
                var cardAccout        = service.GetCardAccountById(mobileTransaction.CardAccountID);
                var bankAccout        = service.GetBankAccountById(cardAccout.BankAccountID);
                var currency          = service.GetCurrencyById(bankAccout.CurrencyID);

                HistoryPaymentDetails info = new HistoryPaymentDetails();
                info.BackRouteValues = RouteValues;
                info.Dictionary      = new Dictionary <string, string>();
                info.Dictionary.Add("Дата", mobileTransaction.Date.ToString());
                info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber));
                info.Dictionary.Add("Оператор", mobileTransaction.MobileProvider);
                info.Dictionary.Add("Номер телефона", mobileTransaction.Phone);
                info.Dictionary.Add("Сумма", mobileTransaction.Amount + " " + currency.ShortName);

                return(View("Details", info));
            }

            if (type == PaymentType.Arbitrary.ToString())
            {
                var transaction = service.GetArbitraryTransactionById(Int32.Parse(id));
                var cardAccout  = service.GetCardAccountById(transaction.CardAccountID);
                var bankAccout  = service.GetBankAccountById(cardAccout.BankAccountID);
                var currency    = service.GetCurrencyById(bankAccout.CurrencyID);

                HistoryPaymentDetails info = new HistoryPaymentDetails();
                info.BackRouteValues = RouteValues;
                info.Dictionary      = new Dictionary <string, string>();
                info.Dictionary.Add("Дата", transaction.Date.ToString());
                info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber));
                info.Dictionary.Add("УНП", transaction.UNP);
                info.Dictionary.Add("Номер счета получателя", transaction.RecipientAccount);
                info.Dictionary.Add("Получатель", transaction.Recipient);
                info.Dictionary.Add("Цель", transaction.Target);
                info.Dictionary.Add("Сумма", transaction.Amount + " " + currency.ShortName);

                return(View("Details", info));
            }

            if (type == PaymentType.Transfer.ToString())
            {
                var transaction = service.GetTransferTransactionById(Int32.Parse(id));
                var cardAccout  = service.GetCardAccountById(transaction.CardAccountID);
                var bankAccout  = service.GetBankAccountById(cardAccout.BankAccountID);
                var currency    = service.GetCurrencyById(bankAccout.CurrencyID);

                HistoryPaymentDetails info = new HistoryPaymentDetails();
                info.BackRouteValues = RouteValues;
                info.Dictionary      = new Dictionary <string, string>();
                info.Dictionary.Add("Дата", transaction.Date.ToString());
                info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber));
                string targetNumber = service.GetCardAccountById(transaction.TargetCardAccountID).CardNumber;
                info.Dictionary.Add("Номер карты получателя", CardAccountModule.ConvertCardNumberString(targetNumber));
                info.Dictionary.Add("Сумма", transaction.Amount + " " + currency.ShortName);

                return(View("Details", info));
            }

            if (type == PaymentType.SSIS.ToString())
            {
                var transaction = service.GetSSISTransactionById(Int32.Parse(id));
                var cardAccout  = service.GetCardAccountById(transaction.CardAccountID);
                var bankAccout  = service.GetBankAccountById(cardAccout.BankAccountID);
                var currency    = service.GetCurrencyById(bankAccout.CurrencyID);
                var payment     = rep.SSISPayments.GetSingle(transaction.SSISPaymentID);

                HistoryPaymentDetails info = new HistoryPaymentDetails();
                info.BackRouteValues = RouteValues;
                info.Dictionary      = new Dictionary <string, string>();
                info.Dictionary.Add("Дата", transaction.Date.ToString());
                info.Dictionary.Add("Номер карты", CardAccountModule.ConvertCardNumberString(cardAccout.CardNumber));
                info.Dictionary.Add("Имя ЕРИП платежа", payment.Name);
                info.Dictionary.Add(payment.NumberLabel, transaction.Number);
                info.Dictionary.Add("Сумма", transaction.Amount + " " + currency.ShortName);

                return(View("Details", info));
            }

            return(View("Index"));
        }
Example #2
0
        public ActionResult Transfer(TransferModel 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.CardId = cardId;
                CardAccount c = service.GetCardAccountById(cardId);
                if (c == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Карта не найдена");
                    return(View(paymentInfo));
                }
                paymentInfo.CardNumber = 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 targetCard = service.GetCardAccountByNumber(paymentInfo.TargetCardAccountNumber);
                if (targetCard == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Не найдена карта с таким номером");
                    return(View(paymentInfo));
                }
                var bankAccount       = service.GetBankAccountById(c.BankAccountID);
                var targetBankAccount = service.GetBankAccountById(targetCard.BankAccountID);
                if (targetBankAccount == null || bankAccount == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ошибка базы");
                    return(View(paymentInfo));
                }
                paymentInfo.TargetCardAccountId = targetCard.CardAccountID;
                if (targetBankAccount.BankAccountID == bankAccount.BankAccountID)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Нельзя переводить на этот же счет");
                    return(View(paymentInfo));
                }
                var currency       = service.GetCurrencyById(bankAccount.CurrencyID);
                var targetCurrency = service.GetCurrencyById(targetBankAccount.CurrencyID);
                if (currency.CurrencyID != targetCurrency.CurrencyID)
                {
                    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("ConfirmTransfer", paymentInfo));
            }
            else
            {
                return(View(paymentInfo));
            }
        }
Example #3
0
        public override bool Execute()
        {
            if (IdClient <= 0)
            {
                Information = StringSource.ClientNotFound();
                return(false);
            }

            var info = new StringBuilder();

            using (var localrepos = new Repositories()) {
                Client = localrepos.Customers.GetSingle(IdClient);
                if (Client == null)
                {
                    Information = StringSource.ClientNotFound();
                    return(false);
                }
                Client.AccessCards = Client.AccessCards.ToList();
                foreach (var el in Client.AccessCards)
                {
                    el.AccessCodes = localrepos.AccessCodes.GetAll(el2 => el2.AccessCardID == el.AccessCardID).ToList();
                }
            }

            info.Append(StringSource.ClientInformation(Client, true));

            Currency    currency = null;
            BankAccount bankacc  = null;

            CardAccount[] cardaccounts = null;
            using (var bankservice = new BankServiceClient()) {
                cardaccounts = bankservice.GetCardAccountsByCustomerId(Client.CustomerID);
                if (cardaccounts == null || cardaccounts.Length <= 0)
                {
                    info.Append(StringSource.CardAccountNotFound());
                }
                foreach (var el in cardaccounts)
                {
                    bankacc = bankservice.GetBankAccountById(el.BankAccountID);
                    if (bankacc == null)
                    {
                        info.Append(StringSource.BankAccountNotFound());
                    }
                    else
                    {
                        currency = bankservice.GetCurrencyById(bankacc.CurrencyID);
                        if (currency == null)
                        {
                            info.Append(StringSource.CurrencyNotFound());
                        }
                        else
                        {
                            info.Append(StringSource.CardAccountInformation(el, bankacc, currency));
                        }
                    }
                }
            }



            Information = info.ToString();
            return(true);
        }