Esempio n. 1
0
        public bool CalcWaterUsage(WaterUsageRate waterUsageRate)
        {
            var waterUsage   = waterUsageRate.WaterUsage;
            var buildingType = waterUsageRate.BuildingType;
            var residence    = waterUsageRate.Residence;

            var sum = CalcPlumping(waterUsage?.Plumbing, buildingType)
                      + CalcGroundWater(waterUsage?.GroundWater, buildingType)
                      + CalcPool(waterUsage?.Pool)
                      + CalcRiver(waterUsage?.River)
                      + CalcIrrigation(waterUsage?.Irrigation)
                      + CalcRain(waterUsage?.Rain)
                      + CalcBuying(waterUsage?.Buying);

            var member = residence?.MemberCount ?? 1;
            var rate   = sum / member;

            return(3.65 <= rate && rate <= 164.25);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var jsonString = @"{ 'plumbing':{ 'mwa':{ 'doing':false,'qualityProblem':{ 'hasProblem':null,'problem':{ 'turbidWater':false,'saltWater':false,'smell':false,'filmOfOil':false,'fogWater':false,'hardWater':false} },'plumbingUsage':{ 'waterQuantity':null,'cubicMeterPerMonth':null,'waterBill':null} },'pwa':{ 'doing':true,'qualityProblem':{ 'hasProblem':false,'problem':{ 'turbidWater':false,'saltWater':false,'smell':false,'filmOfOil':false,'fogWater':false,'hardWater':false} },'plumbingUsage':{ 'waterQuantity':'2','cubicMeterPerMonth':null,'waterBill':'200'} },'other':{ 'doing':false,'qualityProblem':{ 'hasProblem':null,'problem':{ 'turbidWater':false,'saltWater':false,'smell':false,'filmOfOil':false,'fogWater':false,'hardWater':false} },'plumbingUsage':{ 'waterQuantity':null,'cubicMeterPerMonth':null,'waterBill':null} },'waterActivityMWA':{ 'drink':null,'plant':null,'farm':null,'agriculture':null,'product':null,'service':null},'waterActivityPWA':{ 'drink':'50','plant':'50','farm':null,'agriculture':null,'product':null,'service':null},'waterActivityOther':{ 'drink':null,'plant':null,'farm':null,'agriculture':null,'product':null,'service':null},'hasWaterNotRunning':false,'waterNotRunningCount':null},'groundWater':{ 'privateGroundWater':{ 'doing':false,'allCount':null,'waterResourceCount':null,'waterResources':[]},'publicGroundWater':{'doing':false,'waterResourceCount':null,'waterResources':[]}},'pool':{'doing':false,'poolCount':null,'hasSameSize':true,'waterResourceCount':null,'poolSizes':[],'waterResources':[]}}";
            var waterUsage = JsonConvert.DeserializeObject <WaterUsage>(jsonString);

            var residential = new Residential();

            var waterUsageRate = new WaterUsageRate
            {
                // some field from Unit (HouseHoldSample)
                WaterUsage = waterUsage,
                Residence  = residential,
                // some field from Building (BuildingSample)
                BuildingType = (BuildingType)1,
            };

            var calc       = new CalculateWaterUsage();
            var hasWarning = calc.CalcWaterUsage(waterUsageRate);

            System.Console.WriteLine($"hasWarning is {hasWarning}");
        }