Exemplo n.º 1
0
 public ActionResult Login(User user)
 {
     using (SMSDBContext db = new SMSDBContext())
     {
         var usr = db.Users.SingleOrDefault(u => u.UserId == user.UserId && u.UserPassword == user.UserPassword);
         if (usr != null)
         {
             var id = user.UserId.ToString();
             Session["USERID"] = id;
             Session["USER"]   = "******";
             return(RedirectToAction("Home", "Users"));
         }
         else
         {
             ModelState.AddModelError("", "Invalid!");
         }
     }
     return(View());
 }
Exemplo n.º 2
0
 public ActionResult Login(Admin admin)
 {
     using (SMSDBContext db = new SMSDBContext())
     {
         Admin usr = db.Admins.SingleOrDefault(u => u.AdminId == admin.AdminId && u.AdminPassword == admin.AdminPassword);
         if (usr != null)
         {
             var id = admin.AdminId.ToString();
             Session["ADMINID"] = id;
             Session["ADMIN"]   = "admin";
             return(RedirectToAction("Home", "Admins"));
         }
         else
         {
             ModelState.AddModelError("", "Invalid!");
         }
     }
     return(View());
 }
Exemplo n.º 3
0
 public ActionResult Login(Salesman salesman)
 {
     using (SMSDBContext db = new SMSDBContext())
     {
         var usr = db.Salesmans.SingleOrDefault(u => u.SalesmanId == salesman.SalesmanId && u.SalesmanPassword == salesman.SalesmanPassword);
         if (usr != null)
         {
             var id = salesman.SalesmanId.ToString();
             Session["SALESMANID"] = id;
             Session["SALESMAN"]   = "salesman";
             return(RedirectToAction("Home", "Salesmen"));
         }
         else
         {
             ModelState.AddModelError("", "Invalid!");
         }
     }
     return(View());
 }