コード例 #1
0
        public ActionResult Create()
        {
            HostDinner dinner = new HostDinner();
            dinner.DinnerDetail.EventDate = DateTime.Now.AddDays(7);

            return View(new HostDinnerFormViewModel(dinner));
        }
コード例 #2
0
        public ActionResult Create(HostDinner hostDinner)
        {
            if (ModelState.IsValid)
            {
                using (var s = db.CreateUnitOfWork())
                {
                    NerdIdentity nerd = (NerdIdentity)User.Identity;

                    DinnerRVSP rsvp = new DinnerRVSP();
                    rsvp.AttendeeName = nerd.FriendlyName;

                    CreateHostDinnerContext ctx = new CreateHostDinnerContext();
                    ctx.Bind(hostDinner)
                        .CreateHostDinner(nerd.Name,nerd.FriendlyName,rsvp);

                    s.Insert(hostDinner);
                    s.Commit();

                    return RedirectToAction("Details", new { id = hostDinner.Id });
                }
            }

            return View(new HostDinnerFormViewModel(hostDinner));
        }
コード例 #3
0
        private JsonDinner JsonDinnerFromDinner(HostDinner dinner)
        {
            return new JsonDinner
            {
                DinnerID = dinner.Id,
                EventDate = dinner.DinnerDetail.EventDate,
                Latitude = dinner.DinnerMapLocation.Latitude,
                Longitude = dinner.DinnerMapLocation.Longitude,
                Title = dinner.DinnerDetail.Title,
                Description = dinner.DinnerDetail.Description,
                RSVPCount = dinner.RVSPs.Count,

                //TODO: Need to mock this out for testing...
                //Url = Url.RouteUrl("PrettyDetails", new { Id = dinner.DinnerID } )
                Url = "HostDinners/Details/"+dinner.Id.ToString()
            };
        }