public IActionResult DeleteEvent(int id) { List <UserActivities> Coordinator = _context.User_Activity_Join.Where(c => c.activityid == id).ToList(); foreach (var c in Coordinator) { _context.User_Activity_Join.Remove(c); } Playit remove = _context.Activities.SingleOrDefault(b => b.activityid == id); _context.Activities.Remove(remove); _context.SaveChanges(); return(RedirectToAction("Allactivities")); }
public IActionResult CreateActivity(Playit model, string span) { if (ModelState.IsValid) { Playit NewActivity = new Playit { activity = model.activity, date = model.date, time = model.time, duration = model.duration + span, description = model.description, userid = (int)HttpContext.Session.GetInt32("userid") }; _context.Activities.Add(NewActivity); _context.SaveChanges(); HttpContext.Session.SetInt32("activityid", NewActivity.activityid); int id = (int)HttpContext.Session.GetInt32("activityid"); return(RedirectToAction("activitydescription", new { id = id })); } return(View("create", model)); }