示例#1
0
        private void HandleDelete(IEnumerable <RoleMedia> RoleMediaDetails)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            Role   role = null;
            Return obj  = BaseMapper.GenerateReturn();

            foreach (RoleMedia RoleMediaDetail in RoleMediaDetails)
            {
                obj  = RolesMediasMapper.DeletePermanently(RoleMediaDetail);
                role = RoleMediaDetail.Role;
            }

            if (!obj.IsError)
            {
                IEnumerable <UserMedia> userMediaDetails = selectedItem.Media.UsersMedias.Where(i => i.User.IsInRole(role));

                foreach (UserMedia userMediaDetail in userMediaDetails)
                {
                    UsersMediasMapper.DeletePermanently(userMediaDetail);
                }

                Bind();
            }

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error deleting association", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully deleted association");
                Bind();
            }
        }
示例#2
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            selectedItem = BaseMapper.GetObjectFromContext((MediaDetail)selectedItem);
            IEnumerable <RoleMedia> RoleMediaDetails = RolePermissionsSelector.GetRoleMediaDetails();

            Role role = RolePermissionsSelector.GetSelectedRole();
            IEnumerable <RoleMedia> removeItems = selectedItem.Media.RolesMedias.Where(i => i.RoleID == role.ID);

            foreach (RoleMedia removeItem in removeItems)
            {
                RolesMediasMapper.DeletePermanently(removeItem);
            }

            foreach (RoleMedia RoleMediaDetail in RoleMediaDetails)
            {
                selectedItem.Media.RolesMedias.Add(RoleMediaDetail);
            }

            Return obj = MediaDetailsMapper.Update(selectedItem);

            if (obj.IsError)
            {
                BasePage.DisplayErrorMessage("Error assigning role", obj.Error);
            }
            else
            {
                BasePage.DisplaySuccessMessage("Successfully assigned role");
                Bind();
                EditPanel.Visible = false;
            }
        }
示例#3
0
        private void Bind()
        {
            if (selectedItem == null)
            {
                return;
            }

            this.ItemList.DataSource = RolesMediasMapper.GetRoles(selectedItem.Media.RolesMedias);
            this.ItemList.DataBind();
        }
示例#4
0
        protected void DeleteRole_Click(object sender, EventArgs e)
        {
            var id = ((LinkButton)sender).CommandArgument;

            if (!string.IsNullOrEmpty(id))
            {
                var item = selectedItem.History.SingleOrDefault(i => i.ID == long.Parse(id));

                IEnumerable <RoleMedia> RoleMediaDetails = new List <RoleMedia>();

                if (ItemList.SelectedValue != null)
                {
                    Role role = RolesMapper.GetByID(long.Parse(ItemList.SelectedValue.ToString()));
                    RoleMediaDetails = RolesMediasMapper.GetByRole(role, selectedItem);
                }

                HandleDelete(RoleMediaDetails);
            }
        }
        private void Bind()
        {
            if (RoleSelector.ComboBox.SelectedValue != "")
            {
                OnRoleSelectPanel.Visible = true;
                Role role = RolesMapper.GetByID(long.Parse(RoleSelector.ComboBox.SelectedValue));

                if (role == null)
                {
                    return;
                }

                PermissionsSelector.ShowPermissions(role.Permissions);

                if (AdminBasePage.SelectedMediaDetail != null)
                {
                    PermissionsSelector.SetSelectedPermissions(RolesMediasMapper.GetRolePermissions(role, AdminBasePage.SelectedMediaDetail));
                }
            }
        }