Example #1
0
        public ActionResult ConfirmMobile(MobilePaymentModel paymentInfo, FormCollection collcetion)
        {
            if (paymentInfo.CardAccountID == 0)
            {
                return(RedirectToAction("Index"));
            }
            if (paymentInfo.ToOwnPayments)
            {
                OwnPaymentsModule.AddMobileOwnPayment(paymentInfo, rep, WebSecurity.CurrentUserId);
            }
            MobileTransaction mt = new MobileTransaction();

            mt.Amount         = paymentInfo.Amount;
            mt.CardAccountID  = paymentInfo.CardAccountID;
            mt.CustomerID     = WebSecurity.CurrentUserId;
            mt.Date           = Time.GetTime();
            mt.MobileProvider = paymentInfo.Provider;
            mt.Phone          = paymentInfo.Phone;
            mt.Type           = PaymentType.Mobile;
            bool success = service.CreateMobileTransaction(mt);

            if (success)
            {
                return(View("Message", (object)"Платеж успешно завершен"));
            }
            else
            {
                return(View("Message", (object)"Что то пошло не так. Попробуйте еще раз"));
            }
        }
Example #2
0
        public void Execute()
        {
            while (true)
            {
                var autoPays = repo.MobileAutoPayments.GetAll().ToList();

                foreach (var autoPay in autoPays)
                {
                    if (autoPay.LastExecutionDate == new DateTime(2000, 1, 1, 1, 1, 1))
                    {
                        if (autoPay.StartDate <= Time.GetTime())
                        {
                            var  transaction = PrepareTransaction(autoPay);
                            bool sucess      = service.CreateMobileTransaction(transaction);
                            if (sucess)
                            {
                                autoPay.LastExecutionDate = Time.GetTime();
                                repo.MobileAutoPayments.Update(autoPay);
                                repo.SaveChanges();
                            }
                        }
                    }
                    else
                    {
                        if (autoPay.LastExecutionDate.AddTicks(autoPay.Interval.Ticks) <= Time.GetTime())
                        {
                            var  transaction = PrepareTransaction(autoPay);
                            bool sucess      = service.CreateMobileTransaction(transaction);
                            if (sucess)
                            {
                                autoPay.LastExecutionDate = Time.GetTime();
                                repo.MobileAutoPayments.Update(autoPay);
                                repo.SaveChanges();
                            }
                        }
                    }
                }
                Thread.Sleep(new TimeSpan(0, 0, 1, 0));
            }
        }