示例#1
0
        public IActionResult Add(IFormCollection form)
        {
            var PolicyCreation = API.Policy.Create();
            IEmegenlerPolicyAccess AuthBase;

            if (form["SelectedAccessRole"] == "1")
            {
                AuthBase = PolicyCreation.WithUser(form["SelectedUser"]);
            }
            else if (form["SelectedAccessRole"] == "2")
            {
                AuthBase = PolicyCreation.WithRole(form["SelectedGroup"]);
            }
            else
            {
                AuthBase = PolicyCreation.WithUser(form["SelectedUser"]);
            }


            if (form["SelectedElementType"] == "1")
            {
                var PagePolicy = AuthBase.AddPage(form["SelectedPage"]);
                if (form["SelectedPageRule"] == "AccessGranted")
                {
                    PagePolicy.AccessGranted();
                }
                else if (form["SelectedPageRule"] == "AccessDenied")
                {
                    PagePolicy.AccessDenied();
                }
            }
            else if (form["SelectedElementType"] == "2")
            {
                var ReportPolicy = AuthBase.AddComponent(form["SelectedReport"]);
                if (form["SelectedReportRule"] == "Show")
                {
                    ReportPolicy.Show();
                }
                else if (form["SelectedReportRule"] == "Hide")
                {
                    ReportPolicy.Hide();
                }
            }
            else if (form["SelectedElementType"] == "3")
            {
                var FormPolicy = AuthBase.AddForm(form["SelectedForm"]);
                if (form["SelectedFormRule"] == "ActionGranted")
                {
                    FormPolicy.ActionGranted();
                }
                else if (form["SelectedFormRule"] == "Readonly")
                {
                    FormPolicy.Readonly();
                }
                else if (form["SelectedFormRule"] == "Hide")
                {
                    FormPolicy.Hide();
                }
            }
            else if (form["SelectedElementType"] == "4")
            {
                var LinkPolicy = AuthBase.AddLink(form["SelectedLink"]);
                if (form["SelectedLinkRule"] == "ActionGranted")
                {
                    LinkPolicy.ActionGranted();
                }
                else if (form["SelectedLinkRule"] == "Readonly")
                {
                    LinkPolicy.Readonly();
                }
                else if (form["SelectedLinkRule"] == "Hide")
                {
                    LinkPolicy.Hide();
                }
            }

            return(RedirectToAction("Index"));
        }