public ActionResult User(int Code)
        {
            ViewBag.UserTypeId    = new SelectList(dbUser.getUserTypes().ToList(), "UserTypeId", "Description");
            ViewBag.AssignedRoles = new MultiSelectList(dbUser.getUserTypes().ToList(), "UserTypeId", "Description");
            ViewBag.Type          = new SelectList(new List <Object>
            {
                new { value = "M", text = "Mr" },
                new { value = "R", text = "Mrs" },
                new { value = "I", text = "Miss" },
            }, "value", "text");

            if (Code > 0)
            {
                var reqUser = dbUser.GetUserById(Code);
                ViewBag.UserTypeId    = new SelectList(dbUser.getUserTypes().ToList(), "UserTypeId", "Description", reqUser.UserTypeId);
                ViewBag.AssignedRoles = new MultiSelectList(dbUser.getUserTypes().ToList(), "UserTypeId", "Description", reqUser.SMIM_UserAccess_ST.Select(y => y.UserTypeId));
                ViewBag.Type          = new SelectList(new List <Object>
                {
                    new { value = "M", text = "Mr" },
                    new { value = "R", text = "Mrs" },
                    new { value = "I", text = "Miss" },
                }, "value", "text", reqUser.Salutation);
                return(View(reqUser));
            }
            return(View());
        }
        public ActionResult ChangePassword(int?user, int?OrgId, int?CompanyId, ChangePassword tt)
        {
            MembershipUser mu    = Membership.GetUser(Session["UserInfo"].ToString());
            string         pass  = mu.GetPassword("ok");
            string         myUrl = "/Login";

            if (tt.Newpassword.Length < 6)
            {
                return(Json(new { success = false, response = "Password must be minimum 6 characters." }));
            }

            if (pass == tt.Oldpassword)
            {
                if (mu.ChangePassword(pass, tt.Newpassword))
                {
                    var reqLogin = dbUser.GetUserById(user.Value);//db.HRMS_UserMst_ST.Include(c => c.HRMS_UserType_ST).Where(x => x.UserId == user).FirstOrDefault();
                    if (reqLogin.LoginDate == null)
                    {
                        reqLogin.LoginDate = DateTime.Now;
                        dbUser.UpdateUser(reqLogin);
                    }

                    return(Json(new { success = true, response = myUrl }));
                }
                return(Json(new { success = false, response = "Password change failed. Please contact your administrator." }));
            }

            return(Json(new { success = false, response = "Old password is incorrect." }));
        }
        public bool IsInRole(string roleName, int?userID)
        {
            try
            {
                int UserType = dbUser.GetUserById(userID.Value).UserTypeId.Value;

                int userTypeCount = dbUser.getAccessByUserTypeAndRoleName(UserType, roleName).Count();

                if (userTypeCount > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult _Menu()
        {
            string urlParams = WPS.decryptURL.decryptURLstring(Request.QueryString["q"].ToString());

            string[] arrQryStr = urlParams.Split('?');

            int User      = Convert.ToInt16(arrQryStr[0].Split('=')[1].ToString());
            int OrgId     = arrQryStr[1].Split('=')[1].ToString() == "" ? 0 : Convert.ToInt16(arrQryStr[1].Split('=')[1].ToString());
            int CompanyId = arrQryStr[2].Split('=')[1].ToString() == "" ? 0 : Convert.ToInt16(arrQryStr[2].Split('=')[1].ToString());

            int[] UserAccessTypeIds = new int[1];
            UserAccessTypeIds[0] = dbUser.GetUserById(User).UserTypeId.Value;                            //dbUser.getUserAccessByUserID(User).Select(x => x.UserTypeId).ToList();//

            var UserAccess = dbUser.getAccessByUserTypeByAssignedUserTypes(UserAccessTypeIds.ToArray()); // db.HRMS_Access_ST.Where(x => UserAccessTypeIds.Contains(x.HRMS_UserType_ST.UserTypeId)).Select(x => x.aspnet_Roles.RoleName).ToList();
            var roles      = UserAccess.Select(x => x.RoleId.ToString()).ToList();
            var roleName   = dbUser.getRolesbyRoleId(roles.ToArray()).Select(x => x.RoleName).ToList();
            var Menu       = dbUser.getMenuList();

            Menu = Menu.Where(x => roleName.Contains(x.RoleName)).ToList();
            //Menu = Menu.ToList();

            return(View(Menu));
        }