예제 #1
0
        public IActionResult Cancel(int WeddingId)
        {
            int?LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");

            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            WeddingAttendees RsvpToCancel = dbContext.WeddingAttendees.FirstOrDefault(w => w.WeddingId == WeddingId && w.UserId == (int)LoggedInUserID);

            if (RsvpToCancel != null)
            {
                dbContext.WeddingAttendees.Remove(RsvpToCancel);
                dbContext.SaveChanges();
            }
            return(RedirectToAction("Dashboard"));
        }
예제 #2
0
        public IActionResult RSVP(int WeddingId)
        {
            int?LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");

            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            else if (dbContext.WeddingAttendees.Any(g => g.UserId == (int)LoggedInUserID && g.WeddingId == WeddingId) || dbContext.Weddings.FirstOrDefault(w => w.WeddingId == WeddingId) == null)
            {
                return(RedirectToAction("Dashboard"));
            }
            WeddingAttendees NewLink = new WeddingAttendees();

            NewLink.UserId    = (int)LoggedInUserID;
            NewLink.WeddingId = WeddingId;
            dbContext.WeddingAttendees.Add(NewLink);
            dbContext.SaveChanges();
            return(RedirectToAction("Dashboard"));
        }