Esempio n. 1
0
 //Check login
 public ActionResult Login(string userName, string password)
 {
     if (userName.Length == 0 || password.Length == 0)
     {
         return(Json(new { status = false }));
     }
     else
     {
         tbl_User user = _userService.checkLogin(userName, password);
         if (user != null)
         {
             try
             {
                 // The NavLoginSuccess and ContentLoginSuccess  are displayed in two partial views
                 // We can't normally return two partial views from an action, but we don't want to have another server
                 // call to get the second one, so we render the two partial views into HTML strings and package them into an
                 // an anonymous object, which we then serialize into a JSON object for sending to the client
                 // the client side script will then load these two partial views into the relevant page elements
                 var NavLoginSuccess     = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "NavLoginSuccess", user);
                 var ContentLoginSuccess = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "ContentLoginSuccess", user);
                 return(Json(new { NavLoginSuccess, ContentLoginSuccess, status = true }));
             }
             finally
             {
                 Session.Add(UtilContants.USER_LOGIN, user);
             }
         }
         else
         {
             return(Json(new { status = false }));
         }
     }
 }
Esempio n. 2
0
        // Logout
        public ActionResult Logout()
        {
            tbl_User user = (tbl_User)Session[UtilContants.USER_LOGIN];

            if (user != null)
            {
                try
                {
                    // The NavLoginSuccess and ContentLoginSuccess  are displayed in two partial views
                    // We can't normally return two partial views from an action, but we don't want to have another server
                    // call to get the second one, so we render the two partial views into HTML strings and package them into an
                    // an anonymous object, which we then serialize into a JSON object for sending to the client
                    // the client side script will then load these two partial views into the relevant page elements
                    var NavLogout     = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "NavLogout", null);
                    var ContentLogout = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "ContentLogout", null);

                    var json = Json(new { NavLogout, ContentLogout, status = true });
                    return(json);
                }
                finally
                {
                    Session.Clear();
                }
            }
            else
            {
                return(Json(new { status = false }));
            }
        }
 //Tạo các form passenger render về trang hiện tại
 public ActionResult RenderPassenger(int Adult, int Kid, int Baby, double PriceAdult, double PriceBaby, double PriceKid)
 {
     if (Session[UtilContants.USER_LOGIN] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         BookingDetails BookingDetails = new BookingDetails();
         BookingDetails.PriceAdult = PriceAdult;
         BookingDetails.PriceBaby  = PriceBaby;
         BookingDetails.PriceKid   = PriceKid;
         BookingDetails.Adult      = Adult;
         BookingDetails.Kid        = Kid;
         BookingDetails.Baby       = Baby;
         var listPassenger = MultiPartialView.RenderRazorViewToString(this.ControllerContext, "listPassenger", BookingDetails);
         return(Json(new { status = true, listPassenger }));
     }
 }