Example #1
0
        /// <summary>
        /// Inserts an ACL
        /// </summary>
        /// <param name="acl">ACL</param>
        public void InsertAcl(ACL acl)
        {
            if (acl == null)
            {
                throw new ArgumentNullException("acl");
            }



            _context.ACL.AddObject(acl);
            _context.SaveChanges();
        }
Example #2
0
        /// <summary>
        /// Updates the ACL
        /// </summary>
        /// <param name="acl">ACL</param>
        public void UpdateAcl(ACL acl)
        {
            if (acl == null)
            {
                throw new ArgumentNullException("acl");
            }


            if (!_context.IsAttached(acl))
            {
                _context.ACL.Attach(acl);
            }

            _context.SaveChanges();
        }
Example #3
0
        private static ACL DBMapping(DBACL dbItem)
        {
            if (dbItem == null)
            {
                return(null);
            }

            var item = new ACL();

            item.AclId            = dbItem.AclId;
            item.CustomerActionId = dbItem.CustomerActionId;
            item.CustomerRoleId   = dbItem.CustomerRoleId;
            item.Allow            = dbItem.Allow;

            return(item);
        }
Example #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    var roles = this.CustomerService.GetAllCustomerRoles();
                    if (roles.Count == 0)
                    {
                        lblMessage.Text = GetLocaleResourceString("Admin.ACL.NoRolesDefined");
                        return;
                    }
                    this.ACLService.Enabled = cbACLEnabled.Checked;

                    foreach (GridViewRow row in gvACL.Rows)
                    {
                        foreach (CustomerRole cr in roles)
                        {
                            CheckBox cbAllow = row.FindControl(string.Format("cbAllow_{0}", cr.CustomerRoleId)) as CheckBox;
                            HiddenField hfCustomerActionId = row.FindControl(string.Format("hfCustomerActionId_{0}", cr.CustomerRoleId)) as HiddenField;
                            if (cbAllow == null || hfCustomerActionId == null || String.IsNullOrEmpty(hfCustomerActionId.Value))
                                return;

                            bool allow = cbAllow.Checked;
                            int customerActionId = int.Parse(hfCustomerActionId.Value);

                            var acls = this.ACLService.GetAllAcl(customerActionId, cr.CustomerRoleId, null);
                            if (acls.Count > 0)
                            {
                                ACL acl = acls[0];
                                acl.CustomerActionId = customerActionId;
                                acl.CustomerRoleId = cr.CustomerRoleId;
                                acl.Allow = allow;
                                this.ACLService.UpdateAcl(acl);
                            }
                            else
                            {
                                ACL acl = new ACL()
                                {
                                    CustomerActionId= customerActionId,
                                    CustomerRoleId= cr.CustomerRoleId,
                                    Allow= allow
                                };
                                this.ACLService.InsertAcl(acl);
                            }
                        }
                    }

                    Response.Redirect("ACL.aspx");
                }
                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }