Exemple #1
0
        public ActionResult <WaterUsageByParcelDto> GetWaterUsageByAccountIDAndYear([FromRoute] int accountID,
                                                                                    [FromRoute] int year)
        {
            var parcelDtos = Parcel.ListByAccountIDAndYear(_dbContext, accountID, year).ToList();
            var parcelIDs  = parcelDtos.Select(x => x.ParcelID).ToList();

            var parcelMonthlyEvapotranspirationDtos =
                ParcelMonthlyEvapotranspiration.ListByParcelIDAndYear(_dbContext, parcelIDs, parcelDtos, year);
            var monthlyWaterUsageDtos = parcelMonthlyEvapotranspirationDtos
                                        .GroupBy(x => x.WaterMonth)
                                        .OrderBy(x => x.Key)
                                        .Select(x =>
                                                new MonthlyWaterUsageDto()
            {
                Month = ((DateUtilities.Month)x.Key).ShortMonthName(),
                WaterUsageByParcel = x.OrderBy(y => y.ParcelNumber).Select(y => new ParcelWaterUsageDto
                {
                    ParcelNumber         = y.ParcelNumber,
                    WaterUsageInAcreFeet = y.OverriddenEvapotranspirationRate ?? y.EvapotranspirationRate ?? 0,
                    IsOverridden         = y.OverriddenEvapotranspirationRate != null,
                    IsEmpty = y.IsEmpty
                }).ToList()
            })
                                        .ToList();
            var waterUsageDto = new WaterUsageByParcelDto {
                Year = year, WaterUsage = monthlyWaterUsageDtos.ToList()
            };

            return(Ok(waterUsageDto));
        }
Exemple #2
0
        public ActionResult <List <ParcelMonthlyEvapotranspirationDto> > ListWaterUsagesByParcelAndAccountID([FromRoute] int accountID, [FromRoute] int year)
        {
            var parcelDtos = Parcel.ListByAccountIDAndYear(_dbContext, accountID, year).OrderBy(x => x.ParcelID).ToList();
            var parcelIDs  = parcelDtos.Select(x => x.ParcelID).ToList();
            var parcelMonthlyEvapotranspirationDtos =
                ParcelMonthlyEvapotranspiration.ListByParcelIDAndYear(_dbContext, parcelIDs, parcelDtos, year);

            return(Ok(parcelMonthlyEvapotranspirationDtos));
        }