Example #1
0
        // GET: VMPhotoComments
        //step 2.1 建立Index Action
        public ActionResult Index(int id = 1)
        {
            PhotoComments pc = new PhotoComments()
            {
                photos   = db.Photos.ToList(),
                comments = db.Comments.Where(p => p.PhotoID == id).ToList()
            };

            ViewBag.PID    = id;
            ViewBag.PTitle = db.Photos.Where(p => p.PhotoID == id).FirstOrDefault().Title;


            return(View(pc));
        }
Example #2
0
        //step 3.1 建立Display Action
        public ActionResult Display(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            PhotoComments pc = new PhotoComments()
            {
                photos   = db.Photos.Where(p => p.PhotoID == id).ToList(),
                comments = db.Comments.Where(p => p.PhotoID == id).ToList()
            };

            ViewBag.PID = id;
            //ViewBag.PTitle = db.Photos.Where(p => p.PhotoID == id).FirstOrDefault().Title;


            return(View(pc));
        }