Beispiel #1
0
        public ActionResult Login(User objUser)
        {
            using (IMSEntities5 db = new IMSEntities5())
            {
                var obj = db.Users.Where(a => a.UserEmail.Equals(objUser.UserEmail) && a.UserPassword.Equals(objUser.UserPassword)).FirstOrDefault();
                if (obj != null)
                {
                    Session["UserID"]      = obj.UserId.ToString();
                    Session["UserName"]    = obj.UserName.ToString();
                    Session["UserEmail"]   = obj.UserEmail.ToString();
                    Session["UserPhone"]   = obj.UserPhone.ToString();
                    Session["UserAddress"] = obj.UserAddress.ToString();
                    Session["RoleName"]    = obj.Role.RoleName.ToString();

                    if (obj.Role.RoleName == "Admin")
                    {
                        return(RedirectToAction("Index", "Home"));
                    }

                    else if (obj.Role.RoleName == "Employee")
                    {
                        return(RedirectToAction("POS", "Sale"));
                    }
                }

                else
                {
                    ViewBag.Error = "Username or Password is invalid";
                }
            }

            return(View(objUser));
        }
        public JsonResult GetSearchValue(string search)
        {
            IMSEntities5 db        = new IMSEntities5();
            var          allsearch = (from c in db.Products
                                      where c.ProductName.StartsWith(search)
                                      select new { c.ProductName, c.ProductId });

            return(new JsonResult {
                Data = allsearch, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult Index()
        {
            IMSEntities5 entities = new IMSEntities5();

            return(View(entities.Roles));
        }