Beispiel #1
0
        // User gets points for having less trash collected than the average in the users district
        private void RegisterPointsForCollection(WasteCollection collection)
        {
            var household = Context.Households.Where(x => x.HouseholdId == collection.HouseholdId).FirstOrDefault();

            var districtAverage          = MockedAverageDistributionByDistrict.GetMockedDistribution(household.District);
            var districtAverageTotalBags = districtAverage.PlasticWaste + districtAverage.ResidualWaste + districtAverage.FoodWaste;

            var totalBagsCollected = collection.PlasticWaste + collection.ResidualWaste + collection.FoodWaste;

            var pointsMultiplier = districtAverageTotalBags / totalBagsCollected - 1;
            var pointsGiven      = 100 * pointsMultiplier;

            household.Points += (int)pointsGiven;
        }
Beispiel #2
0
 public ActionResult <TrashDistribution> GetStatisticsForDistrict([FromBody] TimeSpanRequest timespan, District district)
 {
     return(Ok(MockedAverageDistributionByDistrict.GetMockedDistribution(district)));
 }