public ActionResult AccessControl()
        {
            StringBuilder strData                  = new StringBuilder();
            AccessControlOverviewModel model       = new AccessControlOverviewModel();
            List <SiteMap>             siteMapList = new List <SiteMap>();


            model.SiteMapJsonList = new List <AccessControlOverviewModel.JsonSiteMap>();



            using (var proxy = new UserProxy())
            {
                siteMapList = proxy.GetSiteMapByApplicationId(1);
            }
            //Generate Site Map string.
            foreach (SiteMap siteMap in siteMapList.Where(f => f.MapPath.IndexOf("*", StringComparison.InvariantCultureIgnoreCase) == -1))
            {
                model.SiteMapJsonList.Add(new AccessControlOverviewModel.JsonSiteMap
                {
                    SiteMapId       = siteMap.SiteMapId,
                    ParentSiteMapId = siteMap.ParentId.HasValue ? siteMap.ParentId.Value : siteMap.SiteMapId,
                    SiteMapTitle    = siteMap.SiteMapTitle,
                    SiteMapUrl      = Url.Action(Constants.Controllers.User_ManageAccessControl, Constants.Controllers.User, new { id = siteMap.SiteMapId }),
                    Open            = Convert.ToString(false).ToLower()
                });
            }
            return(View(model));
        }
        public ActionResult CreateUserGroupData(UserGroupDetailModel model)
        {
            // Validate
            if (ModelState.IsValid)
            {
                List <SiteMap> siteMapList     = new List <SiteMap>();
                List <SiteMap> siteMapRoleList = new List <SiteMap>();
                SiteMap        list            = new SiteMap();
                UserRole       userRole        = null;
                using (var proxy = new UserProxy())
                {
                    if (proxy.CheckUserGroupExist(model.UserGroupName))
                    {
                        ModelState.AddModelError("User Group Name", Convert.ToString(Resources.Res.RES_Error_Unique));
                    }
                    else
                    {
                        using (var _proxy = new UserProxy())
                        {
                            if ((Utilities.MaxRoleType == RoleType.SystemAdmin) && (Utilities.MaxRoleType != 0))
                            {
                                if (Convert.ToInt32(model.RoleTypeId) == Convert.ToInt32(RoleType.SystemAdmin))
                                {
                                    siteMapList = _proxy.GetSiteMapByApplicationId(1);
                                }
                                if (Convert.ToInt32(model.RoleTypeId) == Convert.ToInt32(RoleType.UserAdmin))
                                {
                                    siteMapRoleList = _proxy.GetSiteMapByApplicationId(1);
                                    foreach (var UserAdminSitmap in siteMapRoleList)
                                    {
                                        if ((UserAdminSitmap.SiteMapTitle == Constants.Controllers.Users) || (UserAdminSitmap.SiteMapTitle == Constants.Controllers.Sitmap_Organization) || (UserAdminSitmap.SiteMapTitle == Constants.Controllers.UserAccount) ||
                                            (UserAdminSitmap.SiteMapTitle == Constants.Controllers.UserGroup))
                                        {
                                            list = _proxy.GetSiteMapBySiteMapById(UserAdminSitmap.SiteMapId);
                                            siteMapList.Add(list);
                                        }
                                    }
                                }
                                else if (Convert.ToInt32(model.RoleTypeId) == Convert.ToInt32(RoleType.NormalUser))
                                {
                                    siteMapRoleList = _proxy.GetSiteMapByApplicationId(1);
                                    foreach (var UserAdminSitmap in siteMapRoleList)
                                    {
                                        if ((UserAdminSitmap.SiteMapTitle == Constants.Controllers.Users) || (UserAdminSitmap.SiteMapTitle == Constants.Controllers.UserAccount))
                                        {
                                            list = _proxy.GetSiteMapBySiteMapById(UserAdminSitmap.SiteMapId);
                                            siteMapList.Add(list);
                                        }
                                    }
                                }

                                else if (Convert.ToInt32(model.RoleTypeId) == Convert.ToInt32(RoleType.RigUser))
                                {
                                    siteMapRoleList = _proxy.GetSiteMapByApplicationId(1);
                                    foreach (var UserAdminSitmap in siteMapRoleList)
                                    {
                                        if ((UserAdminSitmap.SiteMapTitle == Constants.Controllers.Users) || (UserAdminSitmap.SiteMapTitle == Constants.Controllers.UserAccount))
                                        {
                                            list = _proxy.GetSiteMapBySiteMapById(UserAdminSitmap.SiteMapId);
                                            siteMapList.Add(list);
                                        }
                                    }
                                }
                            }
                        }

                        User user = @Utilities.GetCurrentUserInfo();

                        userRole = new UserRole()
                        {
                            Description = Convert.ToString(model.Description),
                            RoleName    = Convert.ToString(model.UserGroupName),
                            RoleType    = model.RoleTypeId.Value,
                            IsADGroup   = false,
                            SiteMaps    = siteMapList,
                            CreatedBy   = Convert.ToString(user.UserName),
                            CreatedDate = DateTime.Now,
                            UpdatedBy   = null,
                            UpdatedDate = null,
                        };
                        proxy.CreateUserGroup(userRole, user);

                        model.ShowSuccessMessage   = true;
                        model.SuccessDirectionPath = string.Format("{0}/{1}", Constants.Controllers.User, Constants.Controllers.User_UserGroup);
                        model.SuccessMessage       = Convert.ToString(Resources.Res.RES_Success);
                    }
                }
            }
            return(View("CreateUserGroup", model));
        }