// GET: /Dinners/Details/2

        public ViewResult Details(int id)
        {
            Dinner dinner = _dinnerRepository.TryGetDinner(id);

            if (dinner == null)
            {
                return(View(ViewNames.NotFound));
            }

            bool modificationIsAuthorized = ModificationIsAuthorized(dinner);
            bool userHasRsvp = dinner.UserHasRsvp(User.Identity.Name);
            var  viewModel   = new DinnerDetailsViewModel(dinner, modificationIsAuthorized, userHasRsvp);

            return(View(viewModel));
        }
Пример #2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dinner dinner = db.Dinners.Find(id);

            if (dinner == null)
            {
                return(HttpNotFound());
            }
            DinnerDetailsViewModel dm = new DinnerDetailsViewModel();
            var rsvps = db.RSVPs.Where(u => u.DinnerId == id).OrderBy(u => u.DinnerId).ToPagedList(1, 10);

            dm.RSVPs     = (PagedList <RSVP>)rsvps;
            dm.RSVPCount = dm.RSVPs.Count();
            dm.Dinner    = db.Dinners.FirstOrDefault(u => u.DinnerId == id);
            return(View(dm));
        }