コード例 #1
0
        public IActionResult Index(Attendee attendee)
        {
            if (ModelState.IsValid)
            {
                _context.Attendee.Add(attendee);
                _context.SaveChanges();

                if (attendee.IsAttending == true)
                {
                    var message = "<strong>" + attendee.FirstName + "</strong>" + " - Thank you for your reservation. " + "<br />" + "We look forward to seeing you!";
                    return RedirectToAction("ThankYou", "Home", new { attending = message });
                }
                else if (attendee.IsAttending == false)
                {
                    var sorry = "<strong>" + attendee.FirstName + "</strong>" + " - We're sad that you won't be joining us in celebrating our special day. " + "<br />" + "<br />" + "If anything changes, please contact us!";
                    return RedirectToAction("Sorry", "Home", new { notAttending = sorry });
                }


                return RedirectToAction("Index");
            }
            return View(attendee);
        }
コード例 #2
0
 public IActionResult Edit(Attendee attendee)
 {
     if (ModelState.IsValid)
     {
         _context.Update(attendee);
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(attendee);
 }