コード例 #1
0
        public ActionResult DeleteGuest(int GuestID)
        {
            JonPartyDBEntities ORM = new JonPartyDBEntities();
            Guest found            = ORM.Guests.Find(GuestID);

            ORM.Guests.Remove(found);
            ORM.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult DeleteDish(int DishID)
        {
            JonPartyDBEntities ORM = new JonPartyDBEntities();
            Dish found             = ORM.Dishes.Find(DishID);

            ORM.Dishes.Remove(found);
            ORM.SaveChanges();

            return(RedirectToAction("DishList"));
        }
コード例 #3
0
        public ActionResult SaveGuest(Guest newGuest)
        {
            JonPartyDBEntities ORM = new JonPartyDBEntities();

            if (newGuest != null)
            {
                ORM.Guests.Add(newGuest);
                ORM.SaveChanges();
            }


            return(RedirectToAction("Summary", newGuest));
        }
コード例 #4
0
        public ActionResult SaveDish(Dish newDish)
        {
            JonPartyDBEntities ORM = new JonPartyDBEntities();

            if (newDish != null)
            {
                ORM.Dishes.Add(newDish);
                ORM.SaveChanges();
            }


            return(RedirectToAction("DishSummary", newDish));
        }
コード例 #5
0
        public ActionResult SaveGuestChanges(Guest updatedGuest)
        {
            JonPartyDBEntities ORM = new JonPartyDBEntities();
            Guest oldGuest         = ORM.Guests.Find(updatedGuest.GuestID);

            oldGuest.FirstName      = updatedGuest.FirstName;
            oldGuest.LastName       = updatedGuest.LastName;
            oldGuest.AttendanceDate = updatedGuest.AttendanceDate;
            oldGuest.EmailAddress   = updatedGuest.EmailAddress;
            oldGuest.PlusOne        = updatedGuest.PlusOne;


            ORM.Entry(oldGuest).State = System.Data.Entity.EntityState.Modified;
            ORM.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public ActionResult SaveDishChanges(Dish updatedDish)
        {
            JonPartyDBEntities ORM = new JonPartyDBEntities();
            Dish oldDish           = ORM.Dishes.Find(updatedDish.DishID);

            oldDish.PersonName      = updatedDish.PersonName;
            oldDish.PhoneNumber     = updatedDish.PhoneNumber;
            oldDish.DishName        = updatedDish.DishName;
            oldDish.DishDescription = updatedDish.DishDescription;
            oldDish.Options         = updatedDish.Options;



            ORM.Entry(oldDish).State = System.Data.Entity.EntityState.Modified;
            ORM.SaveChanges();
            return(RedirectToAction("DishList"));
        }
コード例 #7
0
        public async Task <ActionResult> Registration(RegistrationModel registrationGuest)
        {
            if (ModelState.IsValid)
            {
                var IdentityResult = await UserManager.CreateAsync(new IdentityUser(registrationGuest.UserName), registrationGuest.Password);

                if (IdentityResult.Succeeded)
                {
                    //if the model is valid and it passes identity, we add the user to our User table as well...

                    JonPartyDBEntities ORM = new JonPartyDBEntities();

                    //create the user based on our user model and assign the properties from the identity user to it...
                    var newGuest     = new Guest();
                    var newCharacter = new Character();

                    newGuest.FirstName      = registrationGuest.FirstName;
                    newGuest.LastName       = registrationGuest.LastName;
                    newGuest.AttendanceDate = registrationGuest.AttendanceDate;
                    newGuest.EmailAddress   = registrationGuest.UserName;
                    newGuest.PlusOne        = registrationGuest.PlusOne;

                    newCharacter.EmailAddress = registrationGuest.UserName;
                    newCharacter.Name         = registrationGuest.FavoriteCharacter;

                    //add the user to the ORM and save changes...
                    ORM.Characters.Add(newCharacter);
                    ORM.Guests.Add(newGuest);
                    ORM.SaveChanges();

                    //return home view
                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError("", IdentityResult.Errors.FirstOrDefault());

                return(View());
            }

            return(View());
        }