public IActionResult ViewAllOperations(int SessionId = 0)
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract()
         };
         TempData.Keep("TutorModel");
         return(View(paymentModel));
     }
     return(View(new PaymentModel()));
 }
 public IActionResult Invoice(int OprId)
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User      = userCache.Extract(),
             operation = PaymentDB.GetOprDetails(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION))
         };
         TempData.Keep("TutorModel");
         return(PartialView(paymentModel));
     }
     return(PartialView(new PaymentModel()));
 }
 //Get Sessions as json array for Js Tabulator Library
 public IActionResult GetAllJsonOpr()
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract()
         };
         paymentModel.Operations = PaymentDB.GetAllOperations(GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         TempData.Keep("TutorModel");
         return(Json(paymentModel.Operations));
     }
     return(null);
 }
        //Open Opr Details : Show Opr details and Refund if possible
        public IActionResult OprDetails(int OprId)
        {
            if (TempData["TutorModel"] != null)
            {
                UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
                PaymentModel paymentModel = new PaymentModel
                {
                    User      = userCache.Extract(),
                    operation = PaymentDB.GetOprDetails(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION))
                };
                if (paymentModel.operation == null)
                {
                    return(PartialView(new PaymentModel()));
                }
                Console.WriteLine(paymentModel.operation.Auto);
                Console.WriteLine(paymentModel.operation.PaymentMethodId);
                Console.WriteLine(DateTime.Compare(DateTime.Now, paymentModel.operation.CancelationDate) < 0);
                Console.WriteLine(paymentModel.operation.Captured);
                //if payment is not returned before   &&   not auto payment   &&   made by card    && before cancelation Date   -> THEN CAN BE REFUND
                if (paymentModel.operation.Canceled == 0 && paymentModel.operation.Auto == 0 && paymentModel.operation.PaymentMethodId == LkpDetails["Card"] && DateTime.Compare(DateTime.Now, paymentModel.operation.CancelationDate) < 0)
                {
                    //refund if opr is captured
                    if (paymentModel.operation.Captured == 1)
                    {
                        paymentModel.operation.Action    = "RefundPayment";
                        paymentModel.operation.CanRefund = true;
                    }
                    //Void if opr is not captured yet
                    else
                    {
                        paymentModel.operation.Action  = "VoidPayment";
                        paymentModel.operation.CanVoid = true;
                    }
                }
                else if (paymentModel.operation.Canceled == 1)
                {
                    paymentModel.operation.Action = "Canceled";
                }
                else
                {
                    paymentModel.operation.Action = "NoAction";
                }

                TempData.Keep("TutorModel");
                return(PartialView(paymentModel));
            }
            return(PartialView(new PaymentModel()));
        }
 public IActionResult PayNow1(int SessionId)
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract()
         };
         paymentModel.session     = PaymentDB.GetSessionDetails(SessionId, paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         paymentModel.wallet      = PaymentDB.GetWallet(paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         paymentModel.billingInfo = PaymentDB.GetBillingInfo(userCache.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         TempData.Keep("TutorModel");
         return(PartialView(paymentModel));
     }
     return(PartialView(new PaymentModel()));
 }
 public IActionResult Index()
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract(),
         };
         paymentModel.hasHasBlInfo = PaymentDB.HasBillingInfo(paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         paymentModel.PaidSessions = PaymentDB.GetPaidSessions(paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         Console.WriteLine("Date         Name            Operation     Amount     Captured?");
         TempData.Keep("TutorModel");
         return(View(paymentModel));
     }
     return(View(new PaymentModel()));
 }