public JsonResult CheckName(string userName)
        {
            UserAccountDAL agent = new UserAccountDAL();
            bool res = agent.NameCheck(userName, "");

            if (res)
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }

            else
            {
                return Json(null, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult ChangePassword(PasswordChangeModel pswdChange)
        {
            UserAccountDAL agent = new UserAccountDAL();
            pswdChange.NewPassword = PasswordGenerator.EncryptPassword(pswdChange.NewPassword);

            bool res = agent.PasswordChanger(Session["UserID"].ToString(), pswdChange.OldPassword, pswdChange.NewPassword);

            if (res)
            {
                return RedirectToAction("Index", "Home");
            }

            else
            {
                return View(pswdChange);
            }
        }
        public ActionResult Login(UserLoginModel login)
        {
            UserAccountDAL agent = new UserAccountDAL();
            login.Password = PasswordGenerator.EncryptPassword(login.Password);

            try
            {
                bool res = agent.IDCheck(login.UserName, login.Password);
                if (res)
                {
                    res = agent.RoleCheck(login.UserName, login.Password, login.Role);
                    if (res)
                    {
                        FormsAuthentication.SetAuthCookie(login.UserName, false);
                        Session["UserID"] = login.UserName;
                        Session["UserRole"] = login.Role;

                        if (login.Role.Equals("D"))
                        {
                            return RedirectToAction("DeliveryIndex", "Home");
                        }

                        else if (login.Role.Equals("F"))
                        {
                            return RedirectToAction("AddMenu", "FoodCourtAdmin");
                        }

                        else if (login.Role.Equals("M"))
                        {
                            return RedirectToAction("AddMovie", "MovieAdmin");
                        }

                        else if (login.Role.Equals("P"))
                        {
                            return RedirectToAction("AddVenue", "PartyAdmin");
                        }

                        else if (login.Role.Equals("U"))
                        {
                            return RedirectToAction("Index", "Home");
                        }

                        else
                        {
                            ModelState.AddModelError("", "You do not have admin priveleges. Role unverified.");
                            return View(login);
                        }

                    }

                    else
                    {
                        ModelState.AddModelError("", "You do not have admin priveleges. Role unverified.");
                        return View(login);
                    }
                }

                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    return View(login);
                }
            }

            catch
            {

                return View();
            }
        }
        public string Register(string UserId, string UserName, string JoiningDate, string Password, string EmailId, string PhoneNumber)
        {
            UserAccountDAL agent = new UserAccountDAL();
            UserRegisterModel regUser = new UserRegisterModel();

            regUser.EmployeeID = UserId;
            regUser.Name = UserName;
            regUser.DateOfJoining = Convert.ToDateTime(JoiningDate);
            regUser.PhoneNumber = PhoneNumber;
            regUser.EmailId = EmailId;
            regUser.Password = PasswordGenerator.EncryptPassword(Password);

            try
            {
                bool res = agent.NewUserRegister(regUser);
                if (res)
                {
                    FormsAuthentication.SetAuthCookie(regUser.EmployeeID, false);
                    Session["UserID"] = regUser.EmployeeID;
                    Session["UserRole"] = "U";
                    return "DONE";
                }

                else
                {
                    //ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    //return View(regUser);
                    return "ERROR: Registration incorrect";
                }

            }
            catch
            {
                return "ERROR: Registration incorrect";
            }
        }