Пример #1
0
        public IActionResult FunThingNewProcess(FunThing newFunThing)
        {
            int?sessionId = HttpContext.Session.GetInt32("userId");

            if (ModelState.IsValid)
            {
                /* ********Add to database *********** */
                newFunThing.UserId = (int)sessionId;
                dbContext.Add(newFunThing);
                dbContext.SaveChanges();
                // newFunThing.WeddingId is created after dbContext.SaveChanges();
                var newFunThingId = newFunThing.FunThingId;
                /* *********************************** */

                return(RedirectToAction("FunThingDetails", new { funId = newFunThingId }));
            }
            return(View("FunThingNew"));
        }
Пример #2
0
        public IActionResult removeFunThing()
        {
            /* **************************************************************** */
            // Checks if user has a session before they can view this page
            int?sessionId = HttpContext.Session.GetInt32("userId");

            if (sessionId == null)
            {
                return(RedirectToAction("Index"));
            }
            /* **************************************************************** */

            FunThing funthingObj = dbContext.FunThings.FirstOrDefault(u => u.UserId == sessionId);

            dbContext.Remove(funthingObj);
            dbContext.SaveChanges();

            return(RedirectToAction("dashboard"));
        }
Пример #3
0
        public IActionResult funThingDetails(int funId)
        {
            /* **************************************************************** */
            // Checks if user has a session before they can view this page
            int?sessionId = HttpContext.Session.GetInt32("userId");

            if (sessionId == null)
            {
                return(RedirectToAction("Index"));
            }
            /* **************************************************************** */


            Console.WriteLine(funId);
            // query the wedding using the funId parameter
            FunThing CreatedWedding = dbContext.FunThings.Include(w => w.Participants)
                                      .ThenInclude(w => w.Attendant)
                                      .FirstOrDefault(w => w.FunThingId == funId);

            Console.WriteLine(CreatedWedding);
            // pass the wedding object to the view to be displayed as @Model
            return(View(CreatedWedding));
        }