public async System.Threading.Tasks.Task <ActionResult> GetProvidership(NganLuongPaymentModel nganLuongPayment)
        {
            // Check if the request contains all valid params
            int plan;

            if (nganLuongPayment?.OrderCode == null ||
                !int.TryParse(nganLuongPayment.OrderCode, out plan) ||
                !Constants.PROVIDER_PLAN.Contains(plan))
            {
                return(new HttpStatusCodeResult(400, "Invalid request"));
            }

            // Get current user
            var customerID  = User.Identity.GetUserId();
            var userService = this.Service <IUserService>();
            var user        = await userService.GetAsync(customerID);

            // Calculate the date of IsProviderUntil
            // We will save it into Order_code and then get it back on success
            // To validate and set the new IsProviderUntil of user
            DateTime newIsProviderUntil;

            if (user.IsProviderUntil == null || user.IsProviderUntil < DateTime.Now)
            {
                newIsProviderUntil = DateTime.Now.AddDays(30 * plan);
            }
            else
            {
                newIsProviderUntil = user.IsProviderUntil.Value.AddDays(30 * plan);
            }

            //  validate nganluong params before redirect to nganluong
            var info = new RequestInfoTestTemplate
            {
                bank_code         = nganLuongPayment.BankCode,
                Order_code        = user.Id + " - " + newIsProviderUntil.ToString(),
                order_description = "Test becomeProvider, plan = " + plan + "months",
                return_url        = "http://localhost:65358/becomeProvider/success",
                cancel_url        = "http://localhost:65358/",
                Buyer_fullname    = user.FullName,
                Buyer_email       = user.Email,
                Buyer_mobile      = user.PhoneNumber
            };

            var objNLCheckout = new APICheckoutV3();
            var result        = objNLCheckout.GetUrlCheckout(info, nganLuongPayment.PaymentMethod);

            if (result.Error_code == "00")
            {
                return(Redirect(result.Checkout_url));
            }

            return(new HttpStatusCodeResult(400, "Invalid request"));
        }
        public System.Web.Mvc.ActionResult BookVehicle(BookingConfirmViewModel bookingModel, NganLuongPaymentModel nganLuongPayment)
        {
            var user = HttpContext.GetOwinContext()
                       .GetUserManager <ApplicationUserManager>()
                       .FindById(HttpContext.User.Identity.GetUserId());

            // Check if the request contains all valid params
            if (bookingModel?.Action == null || bookingModel.Receipt?.ID == null || nganLuongPayment == null)
            {
                return(new HttpStatusCodeResult(400, "Invalid request"));
            }

            var bookingService = this.Service <IBookingReceiptService>();
            var bookingReceipt = bookingService.Get(br => br.ID == bookingModel.Receipt.ID &&
                                                    br.CustomerID == user.Id &&
                                                    br.IsPending).FirstOrDefault();

            if (bookingReceipt == null)
            {
                return(new HttpStatusCodeResult(400, "Invalid request"));
            }

            // Act based on the received action's name
            switch (bookingModel.Action)
            {
            case "delete":
                bookingService.Delete(bookingReceipt);
                return(RedirectToAction("Index", "Home"));

            case "change":
                var vehicleID = bookingReceipt.VehicleID;
                bookingService.Delete(bookingReceipt);
                return(RedirectToAction("VehicleInfo", "Home", new { id = vehicleID }));

            case "pay":
                break;

            default:
                return(new HttpStatusCodeResult(400, "Bad request"));
            }

            // Only "pay" action left to handle
            // Now validate nganluong params before redirect to nganluong

            var info = new RequestInfoTestTemplate
            {
                bank_code         = nganLuongPayment.BankCode,
                Order_code        = nganLuongPayment.OrderCode,
                order_description = "Test booking",
                return_url        = "http://localhost:65358/bookingReceipt",
                cancel_url        = "http://localhost:65358/bookingReceipt?canceledBookingID=" + bookingModel.Receipt.ID,
                Buyer_fullname    = user.FullName,
                Buyer_email       = user.Email,
                Buyer_mobile      = user.PhoneNumber,
                time_limit        = Constants.BOOKING_CONFIRM_TIMEOUT_IN_MINUTES.ToString()
            };

            var objNLCheckout = new APICheckoutV3();
            var result        = objNLCheckout.GetUrlCheckout(info, nganLuongPayment.PaymentMethod);

            if (result.Error_code == "00")
            {
                return(Redirect(result.Checkout_url));
            }

            return(new HttpStatusCodeResult(400, "Invalid request"));
        }