Пример #1
0
        public ActionResult LogIn(Models.Registration userr)
        {
            //if (ModelState.IsValid)
            //{
            //  InsureEntities db = new InsureEntities();
            using (var db = new checkintegration.Models.InsureEntities())
            {
                var user = db.Registrations.FirstOrDefault(u => u.UserName == userr.UserName && u.Password == userr.Password);
                if (user != null)
                {
                    if (user.RoleId == 1)
                    {
                        return(RedirectToAction("Dashboard", "Admin"));
                    }
                    else if (user.RoleId == 2)
                    {
                        FormsAuthentication.SetAuthCookie(userr.UserName, false);
                        Session["UserId"] = user.UserID;
                        return(RedirectToAction("Homepage", "Home"));
                    }
                    else
                    {
                        Session["CustId"] = user.UserID;
                        FormsAuthentication.SetAuthCookie(userr.UserName, false);
                        return(RedirectToAction("Surveyor_Index", "Surveyor"));
                    }
                }
            }

            return(View(userr));
        }
Пример #2
0
 public ActionResult LogIn()
 {
     if (Session["UserId"] != null)
     {
         int u    = (int)Session["UserId"];
         var db   = new checkintegration.Models.InsureEntities();
         var user = db.Registrations.Where(m => m.UserID == u).Select(m => m.RoleId).FirstOrDefault();
         if (user == 1)
         {
             return(RedirectToAction("Dashboard", "Admin"));
         }
         else if (user == 2)
         {
             return(RedirectToAction("Homepage", "Home"));
         }
         else
         {
             return(RedirectToAction("Surveyor_Index", "Surveyor"));
         }
     }
     return(View());
 }