コード例 #1
0
ファイル: PolicyManager.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Saves the policy.
        /// </summary>
        /// <param name="dto">The dto.</param>
        public static void SavePolicy(PolicyDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException("dto", String.Format("PolicyDto can not be null"));
            }

            //TODO: check concurrency when updating the records

            //TODO: need to check security roles here,
            // The procedure will be following:
            // 1. Retrieve the record from the database for each category that is about to be updated
            // 2. Check Write permissions (if failed generate the error and exit)
            // 3. Otherwise proceed to update
            // Continue with security checks and other operations

            /*
             * foreach (PolicyDto.PolicyRow row in dto.Policy.Rows)
             * {
             *  // Check Security
             *  IDataReader reader = DataHelper.CreateDataReader(dto.PolicySecurity, String.Format("PolicyId = -1 or PolicyId = {0}", row.PolicyId));
             *  PermissionRecordSet recordSet = new PermissionRecordSet(PermissionHelper.ConvertReaderToRecords(reader));
             *  if (!PermissionManager.CheckPermission(PolicyScope.Policy, Permission.Read, recordSet))
             *  {
             *      row.Delete();
             *      continue;
             *  }
             * }
             * */


            PolicyAdmin admin = new PolicyAdmin(dto);

            admin.Save();
        }
コード例 #2
0
 public ActionResult PolicyAdminRegister(PolicyAdmin admin)
 {
     db.PolicyAdmins.Add(admin);
     db.SaveChanges();
     ViewBag.AdminRegistration = "Registration Successful.";
     return(View());
 }
コード例 #3
0
ファイル: PolicyManager.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Gets the Policy dto, checks permissions and caches results.
        /// </summary>
        /// <param name="policyId">The policy id.</param>
        /// <returns></returns>
        public static PolicyDto GetPolicyDto(int policyId)
        {
            // Assign new cache key, specific for site guid and response groups requested
            //string cacheKey = MarketingCache.CreateCacheKey("Policy", PolicyId.ToString());

            PolicyDto dto = null;

            // check cache first
            //object cachedObject = MarketingCache.Get(cacheKey);

            //if (cachedObject != null)
            //    dto = (PolicyDto)cachedObject;

            // Load the object
            if (dto == null)
            {
                PolicyAdmin Policy = new PolicyAdmin();
                Policy.Load(policyId);
                dto = Policy.CurrentDto;

                // Insert to the cache collection
                //MarketingCache.Insert(cacheKey, dto, MarketingConfiguration.CacheConfig.PolicyCollectionTimeout);
            }

            dto.AcceptChanges();

            return(dto);
        }