Example #1
0
 public IActionResult Dashboard()
 {
     if (HttpContext.Session.GetString("Firstname") != null)
     {
         List <WeddingPlan> OldAllplans = dbContext.WeddingPlanes
                                          .Include(w => w.Guests)
                                          .ToList();
         foreach (WeddingPlan x in OldAllplans)
         {
             if (DateTime.ParseExact(x.Date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) < DateTime.Now)
             {
                 WeddingPlan oneplan = dbContext.WeddingPlanes.FirstOrDefault(w => w.WeddingPlanId == x.WeddingPlanId);
                 dbContext.WeddingPlanes.Remove(oneplan);
                 dbContext.SaveChanges();
             }
         }
         List <WeddingPlan> Allplans = dbContext.WeddingPlanes
                                       .Include(w => w.Guests)
                                       .ToList();
         ViewBag.userid = (int)HttpContext.Session.GetInt32("id");
         return(View(Allplans));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Example #2
0
        public IActionResult RSVP(int PlanId)
        {
            if (HttpContext.Session.GetInt32("UserID") == null)
            {
                return(RedirectToAction("Index", "LoginReg"));
            }
            User CurrentUser = DbContext.Users
                               .SingleOrDefault(u => u.UserId == HttpContext.Session
                                                .GetInt32("UserID"));
            WeddingPlan CurrentWedding = DbContext.WeddingPlans
                                         .Include(w => w.Guests)
                                         .ThenInclude(g => g.User)
                                         .SingleOrDefault(w => w.PlanId == PlanId);
            WeddingGuest thisguest = DbContext.WeddingGuests.Where(w => w.PlanId == PlanId && w.UserId == CurrentUser.UserId).FirstOrDefault();

            if (thisguest != null)
            {
                CurrentWedding.Guests.Remove(thisguest);
            }
            else
            {
                WeddingGuest NewGuest = new WeddingGuest {
                    UserId = CurrentUser.UserId,
                    PlanId = CurrentWedding.PlanId,
                };
                CurrentWedding.Guests.Add(NewGuest);
            }
            DbContext.SaveChanges();
            return(RedirectToAction("Dashboard", "WeddingPlan"));
        }
Example #3
0
        public IActionResult delete(int id)
        {
            WeddingPlan toremove = _context.weddings.SingleOrDefault(detail => detail.weddingplanid == id);

            _context.weddings.Remove(toremove);
            _context.SaveChanges();
            // Other code
            return(RedirectToAction("Main", "home"));
        }
Example #4
0
 public IActionResult Process_newPlan(WeddingPlan WeddingPlan)
 {
     if (ModelState.IsValid)
     {
         WeddingPlan.UserId = HttpContext.Session.GetInt32("active_user").Value;
         _context.Add(WeddingPlan);
         _context.SaveChanges();
         return(RedirectToAction("Dashboard"));
     }
     return(View("AddWeddingPlan"));
 }
Example #5
0
        public IActionResult Delete(int PlanId)
        {
            int?active_user = HttpContext.Session.GetInt32("active_user");

            if (active_user.HasValue)
            {
                WeddingPlan plan = _context.WeddingPlans.FirstOrDefault(p => p.WeddingPlanId == PlanId);
                _context.WeddingPlans.Remove(plan);
                _context.SaveChanges();
                return(RedirectToAction("Dashboard"));
            }
            return(RedirectToAction("Index"));
        }
Example #6
0
        public IActionResult details(int id)
        {
            int?userid = HttpContext.Session.GetInt32("userId");

            if (userid != null)
            {
                WeddingPlan Details = _context.weddings.Include(guest => guest.guestlist).ThenInclude(user => user.User).SingleOrDefault(detail => detail.weddingplanid == id);
                ViewBag.Details = Details;
                // Other code
                return(View("details"));
            }
            return(RedirectToAction("Index", "login"));
        }
Example #7
0
        public IActionResult WeddingDetail(int PlanId)
        {
            if (HttpContext.Session.GetInt32("UserID") == null)
            {
                return(RedirectToAction("Index", "LoginReg"));
            }
            WeddingPlan CurrentWedding = DbContext.WeddingPlans
                                         .Include(w => w.Guests)
                                         .ThenInclude(g => g.User)
                                         .SingleOrDefault(w => w.PlanId == PlanId);

            return(View(CurrentWedding));
        }
Example #8
0
        public IActionResult DeletePlan(int id)
        {
            if (HttpContext.Session.GetInt32("UserID") == null)
            {
                return(RedirectToAction("Index", "LoginReg"));
            }
            WeddingPlan deleteitem = DbContext.WeddingPlans
                                     .SingleOrDefault(p => p.PlanId == id);

            DbContext.WeddingPlans.Remove(deleteitem);
            DbContext.SaveChanges();
            return(RedirectToAction("Dashboard", "WeddingPlan"));
        }
Example #9
0
 public IActionResult SubmitPlan(WeddingPlan newplan)
 {
     if (ModelState.IsValid)
     {
         ViewBag.UserId = HttpContext.Session.GetInt32("UserID");
         DbContext.WeddingPlans.Add(newplan);
         DbContext.SaveChanges();
         return(RedirectToAction("Dashboard", "WeddingPlan"));
     }
     ViewBag.UserId = HttpContext.Session.GetInt32("UserID");
     ViewBag.users  = DbContext.Users;
     return(View("PlanWedding"));
 }
Example #10
0
 public IActionResult Delete(int PlanId)
 {
     if (HttpContext.Session.GetString("Firstname") != null)
     {
         WeddingPlan plan = dbContext.WeddingPlanes.FirstOrDefault(p => p.WeddingPlanId == PlanId);
         dbContext.WeddingPlanes.Remove(plan);
         dbContext.SaveChanges();
         return(RedirectToAction("Dashboard"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Example #11
0
        public IActionResult DisplayOnePlan(int PlanId)
        {
            List <Resevation> guest = _context.Resevations
                                      .Include(r => r.User)
                                      .Where(r => r.WeddingPlanId == PlanId)
                                      .ToList();

            WeddingPlan oneplan = _context.WeddingPlans
                                  .FirstOrDefault(w => w.WeddingPlanId == PlanId);
            DisplayOnePlan DisplayOnePlan = new DisplayOnePlan
            {
                Guest   = guest,
                Oneplan = oneplan
            };

            return(View("DisplayOnePlan", DisplayOnePlan));
        }
Example #12
0
        public IActionResult Display_Plan_Detail(int planid)
        {
            List <Resevation> guest = dbContext.Resevationes
                                      .Include(r => r.User)
                                      .Where(r => r.WeddingPlanId == planid)
                                      .ToList();

            WeddingPlan oneplan = dbContext.WeddingPlanes
                                  .FirstOrDefault(w => w.WeddingPlanId == planid);

            Display_one_plan Display_one_plan = new Display_one_plan
            {
                Guest   = guest,
                Oneplan = oneplan
            };

            return(View(Display_one_plan));
        }
Example #13
0
        public IActionResult create(WeddingValidate wedding)
        {
            int?id = HttpContext.Session.GetInt32("userId");

            if (TryValidateModel(wedding))
            {
                WeddingPlan nw = new WeddingPlan
                {
                    One     = wedding.One,
                    Two     = wedding.Two,
                    Date    = wedding.Date,
                    Address = wedding.Address,
                    userid  = (int)id,
                };
                _context.Add(nw);
                _context.SaveChanges();
                return(View("wedding"));
            }

            return(View("wedding"));
        }
Example #14
0
        public IActionResult Process_newplan(WeddingPlan WeddingPlan)
        {
            if (HttpContext.Session.GetString("Firstname") != null)
            {
                if (ModelState.IsValid)
                {
                    if (DateTime.ParseExact(WeddingPlan.Date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) < DateTime.Now)
                    {
                        ModelState.AddModelError("Date", "Date can not be ealy than today!");
                        return(View("AddWeddingPlan"));
                    }

                    List <string> address = WeddingPlan.Address.Split(',').ToList <string>();

                    if (address.Count != 5)
                    {
                        ModelState.AddModelError("Address", "Invalid Address");
                        return(View("AddWeddingPlan"));
                    }
                    else if (!(int.TryParse(address[3], out int w)))
                    {
                        ModelState.AddModelError("Address", "Invalid Address");
                        return(View("AddWeddingPlan"));
                    }

                    WeddingPlan.UserId = (int)HttpContext.Session.GetInt32("id");
                    dbContext.Add(WeddingPlan);
                    dbContext.SaveChanges();
                    return(RedirectToAction("Dashboard"));
                }
                else
                {
                    return(View("AddWeddingPlan"));
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #15
0
        public IActionResult RSVP(int id)
        {
            int?UserId = HttpContext.Session.GetInt32("UserId");

            ViewData["UserId"] = (int)UserId;

            WeddingPlan plan = _context.weddingplan.Where(p => p.WeddingId == id).SingleOrDefault(u => u.GuestId == UserId);

            if (plan != null)
            {
                _context.weddingplan.Remove(plan);
            }
            else
            {
                _context.weddingplan.Add(new WeddingPlan {
                    WeddingId = id, GuestId = (int)UserId
                });
            }

            _context.SaveChanges();

            return(RedirectToAction("Dashboard"));
        }