Ejemplo n.º 1
0
        public ActionResult Create(Dinner dinner)
        {
            if (ModelState.IsValid)
            {
                var command = new HostDinner(User.Identity.Name);
                new HostDinnerCommandHandler().Handle(command, dinner, db);

                return RedirectToAction("Index");
            }

            return View(dinner);
        }
Ejemplo n.º 2
0
        public static void HostDinner(HostDinner command, Models.Dinner dinner, NerdDinnerContext db)
        {
            dinner.HostedBy = command.HostedBy;

            RSVP rsvp = new RSVP();
            rsvp.AttendeeName = command.HostedBy;

            dinner.RSVPs = new List<RSVP>();
            dinner.RSVPs.Add(rsvp);

            db.Dinners.Add(dinner);
            db.SaveChanges();
        }
 public void Handle(HostDinner command, Dinner dinner, NerdDinnerContext db)
 {
     Aggregates.Dinner.HostDinner(command, dinner, db);
 }