Exemple #1
0
        public ActionResult SaveManagementDataAuthorize(string managementOrgId, string authorizes)
        {
            ChangeRecords <ManagementAuthorizeDTO> records =
                new StoreDataHandler(authorizes).BatchObjectData <ManagementAuthorizeDTO>();


            var curOrganization = _service.GetOrgById(managementOrgId);

            foreach (var updatedRec in records.Updated)
            {
                if (updatedRec.Granted.ToLower() == "true")
                {
                    SA_Authorize role = new SA_Authorize
                    {
                        OrgId             = curOrganization.Id,
                        OrgName           = curOrganization.Name,
                        OrgIdPath         = curOrganization.IdPath,
                        OrgNamePath       = curOrganization.NamePath,
                        AuthorizeRoleId   = updatedRec.RoleId,
                        CreatedBy         = GetCurrentUserName(),
                        CreatedDate       = DateTime.Now,
                        CreatedByIdPath   = GetOrganizationIdPath(),
                        CreatedByNamePath = GetOrganizationNamePath()
                    };
                    _service.AddAuthorize(role);
                }
                else
                {
                    _service.DeleteAuthorize(curOrganization.Id, updatedRec.RoleId);
                }
            }
            _service.Save();

            return(this.Direct());
        }
        public ActionResult SaveManagementAuthorize(string managementOrgId, string authorizes)
        {
            ChangeRecords <ManagementAuthorizeDTO> records =
                new StoreDataHandler(authorizes).BatchObjectData <ManagementAuthorizeDTO>();
            SA_Organization managementOrg = _service.GetOrgById(managementOrgId);

            foreach (var rec in records.Updated)
            {
                if (rec.Granted.ToLower() == "true")
                {
                    SA_Authorize authorize = new SA_Authorize();
                    authorize.OrgId             = managementOrg.Id;
                    authorize.OrgName           = managementOrg.Name;
                    authorize.OrgIdPath         = managementOrg.IdPath;
                    authorize.OrgNamePath       = managementOrg.NamePath;
                    authorize.AuthorizeRoleId   = rec.RoleId;
                    authorize.CreatedBy         = GetCurrentUserName();
                    authorize.CreatedDate       = DateTime.Now;
                    authorize.CreatedByIdPath   = GetOrganizationIdPath();
                    authorize.CreatedByNamePath = GetOrganizationNamePath();
                    _service.AddAuthorize(authorize);
                }
                else
                {
                    _service.DeleteAuthorize(managementOrg.Id, rec.RoleId);
                }
            }
            _service.Save();
            return(this.Direct());
        }