public ActionResult DeleteGuest(int GuestID) { JonPartyDBEntities ORM = new JonPartyDBEntities(); Guest found = ORM.Guests.Find(GuestID); ORM.Guests.Remove(found); ORM.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteDish(int DishID) { JonPartyDBEntities ORM = new JonPartyDBEntities(); Dish found = ORM.Dishes.Find(DishID); ORM.Dishes.Remove(found); ORM.SaveChanges(); return(RedirectToAction("DishList")); }
public ActionResult SaveGuest(Guest newGuest) { JonPartyDBEntities ORM = new JonPartyDBEntities(); if (newGuest != null) { ORM.Guests.Add(newGuest); ORM.SaveChanges(); } return(RedirectToAction("Summary", newGuest)); }
public ActionResult SaveDish(Dish newDish) { JonPartyDBEntities ORM = new JonPartyDBEntities(); if (newDish != null) { ORM.Dishes.Add(newDish); ORM.SaveChanges(); } return(RedirectToAction("DishSummary", newDish)); }
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")); }
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")); }
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()); }