public ActionResult Create(Dinners dinner)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    dinner.DinnerID = dinnerRepository.GetDinnerNewId() + 1;
                    dinner.HostedBy = User.Identity.Name;

                    RSVP rsvp = new RSVP();
                    rsvp.RsvpID       = dinnerRepository.GetRsvpNewId() + 1;
                    rsvp.AttendeeName = User.Identity.Name;
                    dinner.RSVP.Add(rsvp);

                    dinnerRepository.Add(dinner);
                    dinnerRepository.Save();
                    return(RedirectToAction("Details", new { id = dinner.DinnerID }));
                }
                catch (Exception e)
                {
                    //ModelState.AddRuleViolations(dinner.GetRuleViolations());
                }
            }
            return(View(new DinnerFormViewModel(dinner)));
        }
Exemple #2
0
        public ActionResult Register(int id)
        {
            Dinners dinner = dinnerRepository.GetDinner(id);

            if (!dinner.IsUserRegistered(User.Identity.Name))
            {
                RSVP rsvp = new RSVP();
                rsvp.RsvpID       = dinnerRepository.GetRsvpNewId() + 1;
                rsvp.AttendeeName = User.Identity.Name;
                dinner.RSVP.Add(rsvp);
                dinnerRepository.Save();
            }
            return(Content("Thanks - we'll see you there!"));
        }