public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } FPAdd.ForecastTime1 = 12; FPAdd.ForecastTime2 = 24; FPAdd.ForecastTime3 = 36; FPAdd.ForecastTime4 = 48; FPAdd.ForecastTime5 = 60; FPAdd.ForecastTimeUTC1 = FPAdd.StartingTimeUTC.AddHours((double)FPAdd.ForecastTime1); FPAdd.ForecastTimeUTC2 = FPAdd.StartingTimeUTC.AddHours((double)FPAdd.ForecastTime2); FPAdd.ForecastTimeUTC3 = FPAdd.StartingTimeUTC.AddHours((double)FPAdd.ForecastTime3); FPAdd.ForecastTimeUTC4 = FPAdd.StartingTimeUTC.AddHours((double)FPAdd.ForecastTime4); FPAdd.ForecastTimeUTC5 = FPAdd.StartingTimeUTC.AddHours((double)FPAdd.ForecastTime5); await _context.SaveChangesAsync(); FPAdd.VerifiedForecasts = new List <VerifiedForecast>(); FPAdd.VerifiedForecasts.Add(new VerifiedForecast() { ForecastTime = 12 }); FPAdd.VerifiedForecasts.Add(new VerifiedForecast() { ForecastTime = 24 }); FPAdd.VerifiedForecasts.Add(new VerifiedForecast() { ForecastTime = 36 }); FPAdd.VerifiedForecasts.Add(new VerifiedForecast() { ForecastTime = 48 }); FPAdd.VerifiedForecasts.Add(new VerifiedForecast() { ForecastTime = 60 }); //FPAdd.VerifiedForecasts.Add(new VerifiedForecast(12, FPAdd)); //FPAdd.VerifiedForecasts.Add(new VerifiedForecast(24, FPAdd)); //FPAdd.VerifiedForecasts.Add(new VerifiedForecast(36, FPAdd)); //FPAdd.VerifiedForecasts.Add(new VerifiedForecast(48, FPAdd)); //FPAdd.VerifiedForecasts.Add(new VerifiedForecast(60, FPAdd)); //FPAdd.VerifiedForecast2 = new VerifiedForecast(24, FPAdd); //FPAdd.VerifiedForecast3 = new VerifiedForecast(36, FPAdd); //FPAdd.VerifiedForecast4 = new VerifiedForecast(48, FPAdd); //FPAdd.VerifiedForecast5 = new VerifiedForecast(60, FPAdd); _context.ForecastPeriods.Add(FPAdd); await _context.SaveChangesAsync(); return(RedirectToPage("Scheduling")); }
public async Task <IActionResult> OnPostAsync(int?FPid) { if (!ModelState.IsValid) { return(Page()); } if (FPid == null) { return(NotFound()); } else { FPEdit.ForecastTimeUTC1 = FPEdit.StartingTimeUTC.AddHours((double)FPEdit.ForecastTime1); FPEdit.ForecastTimeUTC2 = FPEdit.StartingTimeUTC.AddHours((double)FPEdit.ForecastTime2); FPEdit.ForecastTimeUTC3 = FPEdit.StartingTimeUTC.AddHours((double)FPEdit.ForecastTime3); FPEdit.ForecastTimeUTC4 = FPEdit.StartingTimeUTC.AddHours((double)FPEdit.ForecastTime4); FPEdit.ForecastTimeUTC5 = FPEdit.StartingTimeUTC.AddHours((double)FPEdit.ForecastTime5); //------------------------------------------- // Change the VerFor and For associated with this ForPer??? //------------------------------------------- _context.Attach(FPEdit).State = EntityState.Modified; } await _context.SaveChangesAsync(); return(RedirectToPage("Scheduling")); }
public async Task <IActionResult> OnPostAsync(int?FPRemove) { if (FPRemove == null) { return(NotFound()); } else { ForecastPeriod fpRemove = await _context.ForecastPeriods.FindAsync(FPRemove); if (fpRemove != null) { _context.ForecastPeriods.Remove(fpRemove); await _context.SaveChangesAsync(); } return(RedirectToPage("Scheduling")); } }
public async Task <IActionResult> OnPostAsync(int?ForID) { if (!ModelState.IsValid) { return(Page()); } if (ForID == null) { return(NotFound()); } else { _context.Attach(CurrentForecast).State = EntityState.Modified; } await _context.SaveChangesAsync(); return(RedirectToPage("Forecasts")); }
public async Task <IActionResult> OnPostAsync(int?VFid) { if (!ModelState.IsValid) { return(Page()); } if (VFid == null) { return(NotFound()); } else { _context.Attach(VFEdit).State = EntityState.Modified; } await _context.SaveChangesAsync(); return(RedirectToPage("Verifications")); }
public async Task <IActionResult> OnGetAsync(int?FPid) { ForecastPeriods = await _context.ForecastPeriods.ToListAsync(); ForecastPeriods.Reverse(); if (FPid != null) { CurrentPeriod = await _context.ForecastPeriods.FindAsync(FPid); PersonalForecasts = await _context.Forecasts.Where(x => x.ForecastPeriodID == FPid).ToListAsync(); SelectedForePeriodID = (int)FPid; if (PersonalForecasts.Count == 0 || PersonalForecasts == null) { Forecast tempForecast = new Forecast() { ForecastPeriod = CurrentPeriod, ForecastTime = 12, ForecastPeriodID = (int)FPid }; _context.Forecasts.Add(tempForecast); tempForecast = new Forecast() { ForecastPeriod = CurrentPeriod, ForecastTime = 24, ForecastPeriodID = (int)FPid }; _context.Forecasts.Add(tempForecast); tempForecast = new Forecast() { ForecastPeriod = CurrentPeriod, ForecastTime = 36, ForecastPeriodID = (int)FPid }; _context.Forecasts.Add(tempForecast); tempForecast = new Forecast() { ForecastPeriod = CurrentPeriod, ForecastTime = 48, ForecastPeriodID = (int)FPid }; _context.Forecasts.Add(tempForecast); tempForecast = new Forecast() { ForecastPeriod = CurrentPeriod, ForecastTime = 60, ForecastPeriodID = (int)FPid }; _context.Forecasts.Add(tempForecast); await _context.SaveChangesAsync(); PersonalForecasts = await _context.Forecasts.Where(x => x.ForecastPeriodID == FPid).ToListAsync(); } } return(Page()); }