public IActionResult Delete(int WeddersId) { Wedders NewWedding = _context.Wedders.SingleOrDefault(w => w.WeddersId == WeddersId); _context.Remove(NewWedding); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
public IActionResult Show(int WeddersId) { Wedders AllWeddings = _context.Wedders.Where(w => w.WeddersId == WeddersId) .Include(w => w.Visitors) .ThenInclude(visitors => visitors.Users) .SingleOrDefault(); // Wedders NewWedding = AllWeddings.SingleOrDefault(w => w.WeddersId == WeddersId); ViewBag.Weddings = AllWeddings; return(View()); }
public IActionResult UNRSVP(int WeddersId) { int? CurrentUserId = HttpContext.Session.GetInt32("CurrentUser"); Users DashboardUser = _context.Users.SingleOrDefault(u => u.UserId == (int)CurrentUserId); Wedders NewWedding = _context.Wedders.SingleOrDefault(w => w.WeddersId == WeddersId); Visitors RemoveVisitor = _context.Visitors.SingleOrDefault(v => v.WeddersId == NewWedding.WeddersId && v.UserId == DashboardUser.UserId); _context.Remove(RemoveVisitor); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
public IActionResult PlanWedding(Wedders NewWedding) { int? CurrentUserId = HttpContext.Session.GetInt32("CurrentUser"); Users Creator = _context.Users.SingleOrDefault(u => u.UserId == CurrentUserId); if (ModelState.IsValid) { NewWedding.UserId = (int)CurrentUserId; _context.Wedders.Add(NewWedding); _context.SaveChanges(); // Visitors NewVisitor = new Visitors(){ // UserId = (int)CurrentUserId, // WeddersId = NewWedding.UserId // }; // _context.Visitors.Add(NewVisitor); // _context.SaveChanges(); return(RedirectToAction("Dashboard")); } return(View()); }