Example #1
0
        public ActionResult Index()
        {
            var mobileAutoPayments = repo.MobileAutoPayments.GetAll(m => m.CustomerID == WebSecurity.CurrentUserId).ToList();
            var model = mobileAutoPayments.Select(m => new MobileAutoPayModel()
            {
                MobileAutoPayID = m.MobileAutoPayID,
                Amount          = m.Amount,
                IntervalHours   = m.Interval.Hours,
                IntervalMinutes = m.Interval.Minutes,
                IntervalDays    = m.Interval.Days,
                MobileNumber    = m.MobileNumber,
                CardNumber      = CardAccountModule.ConvertCardNumberString(service.GetCardAccountById(m.PayCardId).CardNumber),
                Operator        = m.MobileOperator,
                StartDate       = m.StartDate,
                StartHours      = m.StartDate.Hour,
                StartMinutes    = m.StartDate.Minute,
                LastPayDate     = m.LastExecutionDate
            }).ToList();

            var customer = repo.Customers.GetSingle(WebSecurity.CurrentUserId);

            ViewBag.FirstName  = customer.FirstName;
            ViewBag.MiddleName = customer.MiddleName;
            ViewBag.LastName   = customer.LastName;
            return(View(model));
        }
Example #2
0
        public JsonResult BlockCard(string cardId)
        {
            CardAccount card = service.GetCardAccountById(Int32.Parse(cardId));

            card.IsLocked = true;
            card.Status   = "Заблокирована";
            service.UpdateCardAccount(card);

            ServerResponse response = new ServerResponse()
            {
                Success = true,
                Info    = cardId,
                Message = card.Status
            };

            return(Json(response));
        }
Example #3
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 #4
0
        public ActionResult Index(FormCollection collection)
        {
            List <HistoryItemModel>       HistoryItems = new List <HistoryItemModel>();
            Dictionary <int, CardAccount> CardAccounts = new Dictionary <int, CardAccount>();
            RouteValueDictionary          RouteValues  = new RouteValueDictionary();

            #region parsing

            List <string> cardIds = new List <string>();
            if (collection["item.CardAccount.CardAccountID"] == null)
            {
                return(View("Index", (object)"Не найдена информация о платежных картах"));
            }
            cardIds = collection["item.CardAccount.CardAccountID"].Split(',').Where(id => id != "false").ToList();

            if (cardIds.Any() == false)
            {
                return(View("Index", (object)"Не выбрана ни одна из карт"));
            }
            RouteValues.Add("item.CardAccount.CardAccountID", collection["item.CardAccount.CardAccountID"]);


            var      dateFrom = collection["datepicker-from"];
            var      dateTo   = collection["datepicker-to"];
            DateTime DateFrom;
            DateTime DateTo;
            try
            {
                DateFrom = String.IsNullOrEmpty(dateFrom) ? DateTime.MinValue : DateTime.Parse(dateFrom);
                DateTo   = String.IsNullOrEmpty(dateTo) ? DateTime.MaxValue : DateTime.Parse(dateTo);
            }
            catch (Exception ex)
            {
                return(View("Index", (object)ex.Message));
            }
            RouteValues.Add("datepicker-from", collection["datepicker-from"]);
            RouteValues.Add("datepicker-to", collection["datepicker-to"]);

            var arbitraryPaymentsParam = collection["arbitrary_payments"];
            var ssispPaymentsParam     = collection["ssisp_payments"];
            var mobilePaymentsParam    = collection["mobile_payments"];
            var transferPaymentsParam  = collection["transfer_payments"];
            if ((arbitraryPaymentsParam == null) && (ssispPaymentsParam == null) && (mobilePaymentsParam == null) &&
                (transferPaymentsParam == null))
            {
                return(View("Index", (object)"Ни один из типов платежей не выбран"));
            }

            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"]);
            #endregion parsing

            #region fill

            foreach (var cardId in cardIds)
            {
                var id = Int32.Parse(cardId);
                CardAccounts.Add(id, service.GetCardAccountById(id));
            }

            if (arbitraryPaymentsParam != null)
            {
                foreach (var cardId in cardIds)
                {
                    var payments = service.GetArbitraryTransactionsByCardId(Int32.Parse(cardId), DateFrom, DateTo);
                    if (payments != null && payments.Any())
                    {
                        foreach (var payment in payments)
                        {
                            HistoryItems.Add(new HistoryItemModel()
                            {
                                Amount        = payment.Amount,
                                CardNumber    = CardAccountModule.ConvertCardNumberString(CardAccounts[payment.CardAccountID].CardNumber),
                                Currency      = service.GetBankAccountCurrencyShortString(CardAccounts[payment.CardAccountID].BankAccountID),
                                Date          = payment.Date,
                                Recipient     = payment.Recipient,
                                TransactionId = payment.ArbitraryTransactionID,
                                Type          = payment.Type
                            });
                        }
                    }
                }
            }
            if (ssispPaymentsParam != null)
            {
                foreach (var cardId in cardIds)
                {
                    var payments = service.GetSSISTransactionsByCardId(Int32.Parse(cardId), DateFrom, DateTo);
                    if (payments != null && payments.Any())
                    {
                        foreach (var payment in payments)
                        {
                            HistoryItems.Add(new HistoryItemModel()
                            {
                                Amount        = payment.Amount,
                                CardNumber    = CardAccountModule.ConvertCardNumberString(CardAccounts[payment.CardAccountID].CardNumber),
                                Currency      = service.GetBankAccountCurrencyShortString(CardAccounts[payment.CardAccountID].BankAccountID),
                                Date          = payment.Date,
                                Recipient     = rep.SSISPayments.GetSingle(payment.SSISPaymentID).Name,
                                TransactionId = payment.SSISTransactionID,
                                Type          = payment.Type
                            });
                        }
                    }
                }
            }
            if (mobilePaymentsParam != null)
            {
                foreach (var cardId in cardIds)
                {
                    var payments = service.GetMobileTransactionsByCardId(Int32.Parse(cardId), DateFrom, DateTo);
                    if (payments != null && payments.Any())
                    {
                        foreach (var payment in payments)
                        {
                            HistoryItems.Add(new HistoryItemModel()
                            {
                                Amount        = payment.Amount,
                                CardNumber    = CardAccountModule.ConvertCardNumberString(CardAccounts[payment.CardAccountID].CardNumber),
                                Currency      = service.GetBankAccountCurrencyShortString(CardAccounts[payment.CardAccountID].BankAccountID),
                                Date          = payment.Date,
                                Recipient     = payment.MobileProvider,
                                TransactionId = payment.MobileTransactionID,
                                Type          = payment.Type
                            });
                        }
                    }
                }
            }
            if (transferPaymentsParam != null)
            {
                foreach (var cardId in cardIds)
                {
                    var payments = service.GetTransferTransactionsByCardId(Int32.Parse(cardId), DateFrom, DateTo);
                    if (payments != null && payments.Any())
                    {
                        foreach (var payment in payments)
                        {
                            HistoryItems.Add(new HistoryItemModel()
                            {
                                Amount        = payment.Amount,
                                CardNumber    = CardAccountModule.ConvertCardNumberString(CardAccounts[payment.CardAccountID].CardNumber),
                                Currency      = service.GetBankAccountCurrencyShortString(CardAccounts[payment.CardAccountID].BankAccountID),
                                Date          = payment.Date,
                                Recipient     = payment.Number,
                                TransactionId = payment.TransferTransactionID,
                                Type          = payment.Type
                            });
                        }
                    }
                }
            }
            #endregion fill

            HistoryListModel model = new HistoryListModel()
            {
                BackRouteValues = RouteValues,
                Items           = HistoryItems.OrderBy(x => x.Date).ToList()
            };

            return(View("HistoryList", model));
        }