Exemplo n.º 1
0
        /// <summary>
        /// Get NLC amount by design capacity and school type
        /// </summary>
        /// <param name="designCapacityRecord">Design capacity of K, E & S</param>
        /// <param name="schoolType">Type of School</param>
        /// <returns>NLC dollar amount</returns>
        private decimal CalculateNLCAmount(DesignCapacity designCapacityRecord, Guid schoolType, string schoolTypeName)
        {
            FilterExpression filterAnd = new FilterExpression();

            filterAnd.Conditions.Add(new ConditionExpression("caps_schooltype", ConditionOperator.Equal, schoolType));
            filterAnd.Conditions.Add(new ConditionExpression("caps_designcapacity", ConditionOperator.GreaterEqual, designCapacityRecord.Kindergarten + designCapacityRecord.Elementary + designCapacityRecord.Secondary));

            QueryExpression query = new QueryExpression("caps_nlcfactor");

            query.ColumnSet.AddColumns("caps_designcapacity", "caps_budget");
            query.Criteria.AddFilter(filterAnd);
            query.AddOrder("caps_designcapacity", OrderType.Ascending);

            EntityCollection results = service.RetrieveMultiple(query);

            tracingService.Trace("Count of Results: {0}", results.Entities.Count);

            if (results.Entities.Count < 1)
            {
                throw new Exception(string.Format("There is no NLC Factor record for the school type: {0} and design capacity: {1}.", schoolTypeName, designCapacityRecord.Kindergarten + designCapacityRecord.Elementary + designCapacityRecord.Secondary));
            }

            var nlcBudget = results.Entities[0].GetAttributeValue <int>("caps_budget");

            tracingService.Trace("NLC Amount: {0}", nlcBudget);

            return(nlcBudget);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get Space Allocation by design capacity and school type
        /// </summary>
        /// <param name="designCapacityRecord">Design capacity of K, E & S</param>
        /// <param name="schoolType">Type of School</param>
        /// <returns>Square metre space allocation</returns>
        private decimal CalculateSpaceAllocation(DesignCapacity designCapacityRecord, Guid schoolType, string schoolTypeName)
        {
            FilterExpression filterAnd = new FilterExpression();

            filterAnd.Conditions.Add(new ConditionExpression("caps_schooltype", ConditionOperator.Equal, schoolType));
            filterAnd.Conditions.Add(new ConditionExpression("caps_designcapacity", ConditionOperator.GreaterEqual, designCapacityRecord.Elementary + designCapacityRecord.Secondary));

            QueryExpression query = new QueryExpression("caps_budgetcalc_spaceallocation");

            query.ColumnSet.AddColumns("caps_designcapacity", "caps_spaceallocation");
            query.Criteria.AddFilter(filterAnd);
            query.AddOrder("caps_designcapacity", OrderType.Ascending);

            EntityCollection results = service.RetrieveMultiple(query);

            tracingService.Trace("Count of Results: {0}", results.Entities.Count);

            if (results.Entities.Count < 1)
            {
                throw new Exception(string.Format("There is no space allocation record for the school type: {0} and design capacity: {1}.", schoolTypeName, designCapacityRecord.Elementary + designCapacityRecord.Secondary));
            }

            var designCapacity = results.Entities[0].GetAttributeValue <decimal>("caps_spaceallocation");

            tracingService.Trace("Design Capacity: {0}", designCapacity);

            if (designCapacityRecord.Kindergarten > 0)
            {
                //now add kindergarten
                var kClassSize = GetBudgetCalculationValue("Design Capacity Kindergarten");
                var kRoomSize  = GetBudgetCalculationValue("Kindergarten Space Allocation");

                tracingService.Trace("K Class Size: {0}", kClassSize);
                tracingService.Trace("K Room Size: {0}", kRoomSize);

                var kClassNumber = (int)Math.Ceiling(designCapacityRecord.Kindergarten / kClassSize);

                tracingService.Trace("K Class Number: {0}", kClassNumber);

                return(designCapacity + (kRoomSize * kClassNumber));
            }

            return(designCapacity);
        }