Example #1
0
 public ActionResult Index()
 {
     // Retrieve (database?) or fashion some Blog entities/objects
     // No db? So, make in-memory (or POCO) objects instead & populate ViewModel
     BlogViewModel bvm = new BlogViewModel(); // a BlogViewModel object created
     bvm.Blogs = new List<Blog>()
     {
         new Blog() {BlogTitle = "Ode To Code", BlogAuthor = "Scott Allen", Posts = new List<Post>()},
         new Blog() {BlogTitle = "Hanselman Minutes", BlogAuthor = "Scott Hanselman", Posts = new List<Post>()}
     };
     bvm.NumberOfBlogs = bvm.Blogs.Count;
     ViewBag.Title = "Blog List";
     return View(bvm);
 }
Example #2
0
 public ActionResult Details(string id)
 {
     BlogViewModel bvm = new BlogViewModel();
     bvm.Blogs = new List<Blog>()
     {
         new Blog() {BlogTitle = "Ode To Code", BlogAuthor = "Scott Allen", Posts = new List<Post>()},
         new Blog() {BlogTitle = "Hanselman Minutes", BlogAuthor = "Scott Hanselman", Posts = new List<Post>()}
     };
     bvm.NumberOfBlogs = bvm.Blogs.Count;
     Blog foundBlog = bvm.Blogs.Where(blg => blg.BlogTitle == id).FirstOrDefault();
     if (foundBlog == null) return View;
     ViewBag.Title = "Details of ";
     return View(bvm);
 }