Exemplo n.º 1
0
        public ActionResult Index(int? page)
        {
            //calculate total number of pages
            MicroPostViewModel posts;

            if (page == null) {
                posts = new MicroPostViewModel();
            } else {
                posts = new MicroPostViewModel(page.Value);
            }

            ViewBag.CategoryId =
                new SelectList(db.Categories, "CategoryId", "Name");

            return View(posts);
        }
Exemplo n.º 2
0
        // GET: Categories/Details/5
        public ActionResult Details(int? id, int? page)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Category category = db.Categories.Find(id);
            if (category == null)
            {
                return HttpNotFound();
            }

            MicroPostViewModel posts;
            if (page == null)
                posts = new MicroPostViewModel(1, category);
            else
                posts = new MicroPostViewModel(page.Value, category);

            ViewBag.CategoryId =
                new SelectList(db.Categories, "CategoryId", "Name");
            return View(posts);
        }