public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Info.TestDate = DateTime.ParseExact(DateEdit, "MM/dd/yyyy", null); _context.Attach(Info).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InfoExists(Info.ID)) { return(NotFound()); } else { throw; } } string sessionv = HttpContext.Session.GetString("InfosPage"); return(Redirect(sessionv)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Server).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServerExists(Server.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Info.Add(Info); await _context.SaveChangesAsync(); string sessionv = HttpContext.Session.GetString("InfosPage"); return(Redirect(sessionv)); }
public async Task<IActionResult> OnPostAsync(int? id) { if (id == null) { return NotFound(); } Server = await _context.Server.FindAsync(id); if (Server != null) { _context.Server.Remove(Server); await _context.SaveChangesAsync(); } return RedirectToPage("./Index"); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Info = await _context.Info.FindAsync(id); if (Info != null) { _context.Info.Remove(Info); await _context.SaveChangesAsync(); } string sessionv = HttpContext.Session.GetString("InfosPage"); return(Redirect(sessionv)); }
public async Task <IActionResult> OnPostAsync() { HttpContext.Session.SetString("NoAccess", ""); if (!ModelState.IsValid) { return(Page()); } if (CheckServer.Check(Server)) { HttpContext.Session.SetString("NoAccess", "You do not have access to this server"); NoAccessMsg = HttpContext.Session.GetString("NoAccess"); return(null); } _context.Server.Add(Server); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task OnGetAsync() { IUrlHelper MyUrl = Url; string My = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.ToString() + HttpContext.Request.Path + HttpContext.Request.QueryString; HttpContext.Session.SetString("InfosPage", My); SelectLists(); Check(); FilteredPage = HttpContext.Session.GetString("InfosPage"); var infos = from m in _context.Info select m; if (!string.IsNullOrEmpty(SearchKBID)) { infos = infos.Where(s => s.KBID.Contains(SearchKBID)); } if (!string.IsNullOrEmpty(SearchICW)) { infos = infos.Where(s => s.ICW.Contains(SearchICW)); } if (!string.IsNullOrEmpty(SelectedResult)) { infos = infos.Where(x => x.TestResults == SelectedResult); } if (!string.IsNullOrEmpty(SelectedServer)) { infos = infos.Where(x => x.Server == SelectedServer); } if (!string.IsNullOrEmpty(datefilter)) { string start = datefilter.Split(" - ")[0]; string end = datefilter.Split(" - ")[1]; DateTime startDate = DateTime.ParseExact(start, "MM/dd/yyyy", null); DateTime endDate = DateTime.ParseExact(end, "MM/dd/yyyy", null); infos = infos.Where(d => d.TestDate >= startDate && d.TestDate <= endDate); } foreach (Info temp in _context.Info) { DateTime current = DateTime.Now; if (temp.TestDate <= current.AddMonths(-2)) { temp.Active = "No"; _context.Info.Update(temp); } } Info = await infos.ToListAsync(); await _context.SaveChangesAsync(); }