public async Task <IActionResult> Index() { var pageData = new DashboardPageData(); if (TempData["data"] is string s) { pageData = JsonConvert.DeserializeObject <DashboardPageData>(s); } else { var products = await ProductsProxy.GetProducts(); var expired = new List <Product>(); foreach (var item in products) { if (item.ExpiryDate <= DateTime.Today) { expired.Add(item); } } pageData = new DashboardPageData() { Products = products, Expired = expired }; } return(View(pageData)); }
public async Task <IActionResult> Remove(string Id) { var deleted = false; if (Id != "") { deleted = await ProductsProxy.DeleteProduct(Id); } var products = await ProductsProxy.GetProducts(); var expired = new List <Product>(); foreach (var item in products) { if (item.ExpiryDate <= DateTime.Today) { expired.Add(item); } } var pageData = new DashboardPageData() { Products = products, Expired = expired, ProductRemoved = deleted }; var s = Newtonsoft.Json.JsonConvert.SerializeObject(pageData); TempData["data"] = s; return(RedirectToAction("Index", "Dashboard")); }
public ActionResult StudentDashboard() { ClassDbHandler handler = new ClassDbHandler(); DashboardPageData data = new DashboardPageData(); data.classes = handler.getStudentClasses(2); data.userName = handler.getuserInfo(1).fname + handler.getuserInfo(1).lname; return(View(data)); }
public async Task <IActionResult> Logout() { await HttpContext.SignOutAsync(); var pageData = new DashboardPageData() { }; return(View("Login", pageData)); }
public ActionResult Login(string returnUrl = null) { if (_appUser.IsSignedIn) { return(Redirect("/dashboard")); } else { ViewData["ReturnUrl"] = returnUrl; var pageData = new DashboardPageData() { }; return(View(pageData)); } }