public IActionResult Dashboard() { if (HttpContext.Session.GetInt32("User") == null) { return(Redirect("/login")); } List <Wedding> expired = dbContext.weddings .Where(w => DateTime.Compare(w.Date, DateTime.Now) < 0) .ToList(); foreach (Wedding wedding in expired) { dbContext.Remove(wedding); } dbContext.SaveChanges(); List <Wedding> weddings = dbContext.weddings .Include(w => w.GuestList) .ThenInclude(gl => gl.Guest) .ToList(); ViewBag.User = HttpContext.Session.GetInt32("User"); return(View(weddings)); }
public IActionResult Delete() { Int32.TryParse(RouteData.Values["id"].ToString(), out int actId); if (HttpContext.Session.Keys.Contains("userID")) { List <Plan> relatedPlans = dbContext.Plans.Include(p => p.Activity).Where(p => p.Activity.Id == actId).ToList(); Activ specActivity = relatedPlans[0].Activity; foreach (var specPlan in relatedPlans) { dbContext.Remove(specPlan); } dbContext.Remove(specActivity); dbContext.SaveChanges(); return(RedirectToAction("Wall")); } else { return(RedirectToAction("Index")); } }
public IActionResult StartGame() { HttpContext.Session.SetInt32("temp", 200); SetTemp(0); HttpContext.Session.SetInt32("Level", 1); int Id = (int)HttpContext.Session.GetInt32("PlayerId"); Player Player1 = _context.player.SingleOrDefault(p => p.PlayerId == Id); Player1.health = Player1.healthMax; List <Story> story = _context.storyline.Where(p => p.PlayerId == Id).ToList(); foreach (var thing in story) { _context.Remove(thing); } _context.SaveChanges(); return(RedirectToAction("firstEncounter")); }