public IActionResult Delete(int ActivityId)
        {
            Activity a = context.Activities.FirstOrDefault(act => act.ActivityId == ActivityId);

            context.Activities.Remove(a);
            context.SaveChanges();
            return(Redirect("/home"));
        }
        public IActionResult ShowActivity(int ActivityId)
        {
            Activity a = context.Activities
                         .Include(act => act.Planner)
                         .Include(act => act.AttendingUsers)
                         .ThenInclude(act => act.Joiner)
                         .FirstOrDefault(act => act.ActivityId == ActivityId);

            ViewBag.Joins = a.AttendingUsers;
            return(View(a));
        }
 public IActionResult Update(int ActivityId, Activity a)
 {
     if (ModelState.IsValid)
     {
         Activity act = context.Activities.FirstOrDefault(actv => actv.ActivityId == ActivityId);
         act.Title       = a.Title;
         act.Time        = a.Time;
         act.Description = a.Description;
         act.StartTime   = a.StartTime;
         act.Duration    = a.Duration;
         context.SaveChanges();
         return(Redirect("/home"));
     }
     else
     {
         return(View("Edit", a));
     }
 }
        public IActionResult CreateActivity(Activity a)
        {
            int?UserId = HttpContext.Session.GetInt32("UserId");

            if (UserId == null)
            {
                return(Redirect("/"));
            }
            if (ModelState.IsValid)
            {
                a.PlannerId = (int)UserId;
                context.Activities.Add(a);
                context.SaveChanges();
                return(Redirect("/home"));
            }
            else
            {
                return(View("NewActivity", a));
            }
        }
        public IActionResult Edit(int ActivityId)
        {
            Activity act = context.Activities.FirstOrDefault(a => a.ActivityId == ActivityId);

            return(View(act));
        }