Exemple #1
0
        public JsonResult Delete(string Id)
        {
            var custome = repo.Customers.GetSingle(WebSecurity.CurrentUserId);

            ViewBag.FirstName  = custome.FirstName;
            ViewBag.MiddleName = custome.MiddleName;
            ViewBag.LastName   = custome.LastName;

            if (Id != null)
            {
                try
                {
                    MobileAutoPay autoPay = repo.MobileAutoPayments.GetSingle(Int32.Parse(Id));
                    if (autoPay == null)
                    {
                        throw new Exception();
                    }
                    repo.MobileAutoPayments.Remove(autoPay);
                    repo.SaveChanges();

                    ServerResponse response = new ServerResponse()
                    {
                        Success = true,
                        Info    = Id,
                        Message = "Автооплата удалена"
                    };
                    return(Json(response));
                }
                catch (Exception ex)
                {
                    ServerResponse response = new ServerResponse()
                    {
                        Success = false,
                        Info    = Id,
                        Message = "Ошибка удаления автооплаты"
                    };
                    return(Json(response));
                }
            }
            else
            {
                ServerResponse response = new ServerResponse()
                {
                    Success = false,
                    Info    = Id,
                    Message = "Не передан айди автооплаты"
                };
                return(Json(response));
            }
        }
Exemple #2
0
        public MobileTransaction PrepareTransaction(MobileAutoPay model)
        {
            MobileTransaction transaction = new MobileTransaction()
            {
                Amount         = model.Amount,
                CardAccountID  = model.PayCardId,
                CustomerID     = model.CustomerID,
                Date           = Time.GetTime(),
                MobileProvider = model.MobileOperator,
                Phone          = model.MobileNumber,
                Type           = PaymentType.Mobile
            };

            return(transaction);
        }
Exemple #3
0
        public ActionResult ConfirmAutoPay(MobileAutoPayModel paymentInfo, FormCollection collection)
        {
            var custome = repo.Customers.GetSingle(WebSecurity.CurrentUserId);

            ViewBag.FirstName  = custome.FirstName;
            ViewBag.MiddleName = custome.MiddleName;
            ViewBag.LastName   = custome.LastName;

            if (paymentInfo.CardAccountID == 0)
            {
                return(RedirectToAction("Index"));
            }
            MobileAutoPay mt = new MobileAutoPay();

            mt.Amount     = paymentInfo.Amount;
            mt.PayCardId  = paymentInfo.CardAccountID;
            mt.CustomerID = WebSecurity.CurrentUserId;
            DateTime date =
                DateTime.ParseExact(collection["StartDate"], "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            mt.StartDate         = date;
            mt.LastExecutionDate = new DateTime(2000, 1, 1, 1, 1, 1);
            mt.MobileOperator    = paymentInfo.Operator;
            mt.Interval          = new TimeSpan(paymentInfo.IntervalDays, paymentInfo.IntervalHours, paymentInfo.IntervalMinutes, 0);
            mt.MobileNumber      = paymentInfo.MobileNumber;
            try
            {
                repo.MobileAutoPayments.Add(mt);
                repo.SaveChanges();
                return(View("Mesage", (object)"Автооплата успешно создана"));
            }
            catch (Exception ex)
            {
                return(View("Mesage", (object)"Что то пошло не так. Попробуйте еще раз" + ex.Message));
            }
        }