PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/MvcMusicStore/Controllers/StoreController.cs

#
C# | 58 lines | 35 code | 14 blank | 9 comment | 1 complexity | d07e3dc15730dc6176bb9bfd534a7b1d MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Web;
 5using System.Web.Mvc;
 6using MvcMusicStore.Models;
 7
 8namespace MvcMusicStore.Controllers
 9{
10    public class StoreController : Controller
11    {
12        MusicStoreEntities storeDB = new MusicStoreEntities();
13
14        //
15        // GET: /Store/
16
17        public ActionResult Index()
18        {
19            var genres = storeDB.Genres.ToList();
20
21            return View(genres);
22        }
23
24        //
25        // GET: /Store/Browse?genre=Disco
26
27        public ActionResult Browse(string genre)
28        {
29            // Retrieve Genre and its Associated Albums from database
30            var genreModel = storeDB.Genres.Include("Albums")
31                .Single(g => g.Name == genre);
32
33            return View(genreModel);
34        }
35
36        //
37        // GET: /Store/Details/5
38
39        public ActionResult Details(int id)
40        {
41            var album = storeDB.Albums.Find(id);
42
43            return View(album);
44        }
45
46        //
47        // GET: /Store/GenreMenu
48
49        [ChildActionOnly]
50        public ActionResult GenreMenu()
51        {
52            var genres = storeDB.Genres.ToList();
53
54            return PartialView(genres);
55        }
56
57    }
58}