Example #1
0
        public ActionResult SaveUserRights(UserPermissionMasterModel PermittedList)
        {
            ResponseDetail objResponse = new ResponseDetail();
            List <UserPermissionMasterModel> objPermissionList = new List <UserPermissionMasterModel>();

            if (!string.IsNullOrEmpty(PermittedList.ListPermittedMenuList))
            {
                var objects = JArray.Parse(PermittedList.ListPermittedMenuList); // parse as array
                foreach (JObject root in objects)
                {
                    UserPermissionMasterModel objTemp = new UserPermissionMasterModel();
                    foreach (KeyValuePair <String, JToken> app in root)
                    {
                        if (app.Key == "MenuId")
                        {
                            objTemp.MenuId = (decimal)app.Value;
                        }
                        //else if (app.Key == "UserId")
                        //{
                        //    objTemp.UserId = (decimal)app.Value;
                        //}
                        else if (app.Key == "IsPermitted")
                        {
                            objTemp.IsPermitted = (bool)app.Value;
                        }
                    }
                    objTemp.CurrentLoginUser = Session["LoginUser"] as User;
                    objTemp.UserId           = PermittedList.UserId;
                    objPermissionList.Add(objTemp);
                }
            }
            objResponse = objUserManager.SetUserRights(objPermissionList);
            return(Json(objResponse, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult SetUserRights()
        {
            UserPermissionMasterModel objUserList = new UserPermissionMasterModel();

            objUserList.UserList = objUserManager.GetUserList(false);
            if (objUserList.UserList != null && objUserList.UserList.Count() > 0)
            {
                ViewBag.Selecteduser = objUserList.UserList[0].UserId;
            }
            else
            {
                ViewBag.Selecteduser = 0;
            }
            var AccessTo = new UserController().UserCanAccess((Session["LoginUser"] as User).UserId, "SetUserRights");

            if (!string.IsNullOrEmpty(AccessTo))
            {
                ViewBag.UserCanAccess = AccessTo;
                return(View(objUserList));
            }
            else
            {
                return(RedirectToAction("Dashboard", "Home"));
            }
        }
Example #3
0
        public ActionResult SetUserRights()
        {
            UserPermissionMasterModel objUserList = new UserPermissionMasterModel();

            objUserList.UserList = objUserManager.GetUserList();
            if (objUserList.UserList != null && objUserList.UserList.Count() > 0)
            {
                ViewBag.Selecteduser = objUserList.UserList[0].UserId;
            }
            else
            {
                ViewBag.Selecteduser = 0;
            }
            return(View(objUserList));
        }
Example #4
0
        public ActionResult SaveUserRights(UserPermissionMasterModel PermittedList)
        {
            ResponseDetail objResponse = new ResponseDetail();
            List <UserPermissionMasterModel> objPermissionList = new List <UserPermissionMasterModel>();
            string Log = string.Empty;

            if (!string.IsNullOrEmpty(PermittedList.ListPermittedMenuList))
            {
                var objects = JArray.Parse(PermittedList.ListPermittedMenuList); // parse as array
                foreach (JObject root in objects)
                {
                    UserPermissionMasterModel objTemp = new UserPermissionMasterModel();
                    foreach (KeyValuePair <String, JToken> app in root)
                    {
                        if (app.Key == "MenuId")
                        {
                            objTemp.MenuId = (decimal)app.Value;
                        }
                        else if (app.Key == "IsPermitted")
                        {
                            objTemp.IsPermitted = (bool)app.Value;
                        }
                        else if (app.Key == "IsEdit")
                        {
                            objTemp.IsEdit = (bool)app.Value;
                        }
                    }
                    objTemp.CurrentLoginUser = Session["LoginUser"] as User;
                    objTemp.UserId           = PermittedList.UserId;

                    objPermissionList.Add(objTemp);
                }
                Log = "Saved user rights for userid - " + PermittedList.UserId;
            }
            objResponse = objUserManager.SetUserRights(objPermissionList);

            //Added log
            string hostName    = Dns.GetHostName();
            string myIP        = Dns.GetHostEntry(hostName).AddressList[0].ToString();
            string currentDate = DateTime.Now.ToString("yyyyMMddHHmmssfff");;

            objLogManager.SaveLog(Session["LoginUser"] as User, Log, myIP + currentDate);

            return(Json(objResponse, JsonRequestBehavior.AllowGet));
        }