예제 #1
0
        public CoupleAddNewGuestVM CreateViewModelGuest()
        {
            CoupleAddNewGuestVM viewModel = new CoupleAddNewGuestVM
            {
                GuestStatus = guestStatus
            };

            return(viewModel);
        }
예제 #2
0
        public IActionResult AddGuest(CoupleAddNewGuestVM newGuestVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(newGuestVM));
            }

            coupleServices.AddNewGuest(newGuestVM);
            return(RedirectToAction(nameof(GuestList)));
        }
예제 #3
0
        public IActionResult AddGuest(CoupleAddNewGuestVM newGuestVM, string saveAdd, string saveCancel)
        {
            if (!ModelState.IsValid)
            {
                return(View(newGuestVM));
            }

            if (!string.IsNullOrEmpty(saveAdd))
            {
                coupleServices.AddNewGuest(newGuestVM);
                return(RedirectToAction(nameof(AddGuest)));
            }
            else if (!string.IsNullOrEmpty(saveCancel))
            {
                coupleServices.AddNewGuest(newGuestVM);
                return(RedirectToAction(nameof(GuestList)));
            }
            return(RedirectToAction(nameof(GuestList)));  //redirect to something went wrong
        }
예제 #4
0
        public void AddNewGuest(CoupleAddNewGuestVM newGuestVM)
        {
            Guest guest = new Guest()
            {
                Firstname        = newGuestVM.Firstname,
                Lastname         = newGuestVM.Lastname,
                Address          = newGuestVM.Address,
                Email            = newGuestVM.Email,
                InvitedBy        = newGuestVM.InvitedBy,
                GuestTitle       = newGuestVM.GuestTitle,
                WeddingCrewTitle = newGuestVM.WeddingCrewTitle,
                Rsvp             = newGuestVM.SelectedRsvp,
                FoodPreference   = newGuestVM.FoodPreference,
                GuestNote        = newGuestVM.GuestNote,
                Userref          = Userref()
            };

            context.Guest.Add(guest);
            context.SaveChanges();
        }
예제 #5
0
        public void AddNewGuest(CoupleAddNewGuestVM newGuestVM)
        {
            var temp = Userref();   //Hämta parets id tilldela userref för att mappa gäst mot par

            Guest guest = new Guest()
            {
                Firstname        = newGuestVM.Firstname,
                Lastname         = newGuestVM.Lastname,
                Address          = newGuestVM.Address,
                Email            = newGuestVM.Email,
                InvitedBy        = newGuestVM.InvitedBy,
                GuestTitle       = newGuestVM.GuestTitle,
                WeddingCrewTitle = newGuestVM.WeddingCrewTitle,
                Rsvp             = newGuestVM.Rsvp,
                FoodPreference   = newGuestVM.FoodPreference,
                GuestNote        = newGuestVM.GuestNote,
                Userref          = temp
            };

            context.Guest.Add(guest);
            context.SaveChanges();
        }