Exemplo n.º 1
0
        public ActionResult RightToGroupView()
        {
            if (!RightManager.Instance.HasUserRight(RightEnum.ADMINISTRATION___GROUP_RIGHT))
                throw new Exception("Uživatel nemá právo pro přístup ke stránce administrace skupina-právo");

            LinkCssFile("ItemToGroupView.css");
            LinkJavaScriptFile("MatrixTable.js");

            var model = new AdminRightGroupModel()
            {
                GroupList       = Locator.GetDbGroupManager().GetGroupList().Select(ModelConvertor.ConvertToGroupModel).OrderBy(g => g.GroupName).ToList(),
                Right2GroupList = Locator.GetDbRightManager().GetRightList().Select(ModelConvertor.ConvertToRight2Group).OrderBy(r => r.Id).ToList(),
                SelectedGroupId = AdminContrTransporter.SelectedItemId2,
                InfoMessage     = AdminContrTransporter.InfoMessage,
            };

            // we need this db collection. because it contains list of users for each group
            var dbGroupList = Locator.GetDbGroupManager()
                .GetGroupListIncludeUsers(AdminContrTransporter.SelectedItemId2)
                .OrderBy(g => g.GroupName)
                .ToList();

            // lets prepare data for check box matrix
            foreach (var r in model.Right2GroupList)
            {
                r.Groups = new List<AssignedGroup>();

                foreach (var g in dbGroupList)
                {
                    r.Groups.Add(new AssignedGroup()
                    {
                        GroupId          = g.Id,
                        IsInGroup        = g.RIGHT.FirstOrDefault(gl => gl.Id == r.Id) != null,
                        UniqueId         = string.Format("@MyItem_{0}_{1}", g.Id, r.Id),
                        GroupName        = g.GroupName,
                        GroupUserTooltip = string.Format("{0} - {1}", g.GroupName, r.RightName)
                    });
                }
            }

            // just try select proper group
            if (model.GroupList.Count > 0 && AdminContrTransporter.SelectedItemId2 != 0)
                model.ConcreteGroup = model.GroupList.First(u => u.Id == AdminContrTransporter.SelectedItemId2);

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult RightToGroupSelectionChanged(AdminRightGroupModel argm)
        {
            AdminContrTransporter.SelectedItemId2 = argm.SelectedGroupId;

            return RedirectToAction("RightToGroupView", "Admin");
        }