/* * Input: SelectTarget object * Output: Task, SolarViewModel object * Desc: Creates SolarViewModel object based on parameters in info object */ private async Task <SolarViewModel> SVMBuilder(DateRange info) { //SVM default values are empty List<T>. Dates and all facilities are grabbed for GUI SolarViewModel rtn = new SolarViewModel { dateStart = info.dateStart, dateEnd = info.dateEnd, showPower = true, showWeather = true, plantNum = -1, facilities = await _context.Facilities.OrderBy(f => f.PlantNumber) .Select(f => new SVMFacility(f)) .ToListAsync() }; //TODO: These three methods make three seperate accesses to the database and need to probably be one query // execution is deferred until the ToList() when dealing with an IQueryable //Populate WeatherReadings if (rtn.showWeather) { rtn.weatherReadings = await PopulateWeatherReadings(info); } //Populate PowerReadings and sources if (rtn.showPower) { rtn.powerReadings = await PopulatePowerReadings(info); rtn.powerSources = await PopulatePowerSources(info); } return(rtn); }
/* * Input: None * Output: Tas, View * Desc: GET: /Solar * Retrieves info.cshtml page with default selection */ public async Task <IActionResult> Info() { //Get all Facilities for dropdown DateRange info = new DateRange(); SolarViewModel rtn = await SVMBuilder(info); return(View(rtn)); }
public async Task <IActionResult> PostInfo() { DateRange tgt = new DateRange { dateStart = DateTime.Parse(HttpContext.Request.Form["startDate"]), dateEnd = DateTime.Parse(HttpContext.Request.Form["endDate"]) }; tgt.printDebug(); //Create SelectInfo struct from form data SolarViewModel rtn = await SVMBuilder(tgt); return(View(rtn)); }