예제 #1
0
 public HomeModule()
 {
     Get["/"] = _ => {
     List<Cd> allCds = Cd.GetAll();
     return View["index.cshtml", allCds];
       };
       Get["/cds"] = _ => {
     List<Cd> allCds = Cd.GetAll();
     return View["index.cshtml", allCds];
       };
       Get["/cds/new"] = _ => {
     return View["cd_form.cshtml"];
       };
       Post["/"] = _ => {
     Cd newCd = new Cd(Request.Form["new-title"], Request.Form["new-artist"]);
     List<Cd> allCds = Cd.GetAll();
     return View["index.cshtml", allCds];
       };
       Get["/cds/{id}"] = parameters => {
     Cd cd = Cd.Find(parameters.id);
     return View["/cd.cshtml", cd];
       };
       Get["/search_cds"] = _ => View["search_cds.cshtml"];
       Post["/view_result"] = _ =>
       {
     string artist = Request.Form["artist"];
     List<Cd> results = Cd.SearchCd(artist);
     return View["view_result.cshtml", results];
       };
 }
예제 #2
0
 public HomeModule()
 {
     Get["/"] = _ => {
     List<Cd> allCds = Cd.GetAll();
     return View["index.cshtml", allCds];
       };
       Get["/cds"] = _ => {
     List<Cd> allCds = Cd.GetAll();
     return View["index.cshtml", allCds];
       };
       Get["/cds/new"] = _ => {
     return View["cd_form.cshtml"];
       };
       Post["/"] = _ => {
     Cd newCd = new Cd(Request.Form["new-title"]);
     Artist newArtist = new Artist(Request.Form["new-artist"]);
     List<Artist> allArtist = Artist.GetAll();
     List<Cd> allCds = Cd.GetAll();
     return View["index.cshtml", allCds];
       };
       Get["/cds/{id}"] = parameters => {
     Artist artist = Artist.Find(parameters.id);
     return View["/cd.cshtml", artist];
       };
       Get["/search_artist"] = _ => View["search_artist.cshtml"];
       Post["view_result"] = _ =>
       {
     string artist = Request.Form["artist"];
     List<Artist> results = Artist.SearchArtist(artist);
     return View["view_result.cshtml", results];
       };
       Get["/search_artist/{id}"] = parameters =>
       {
     Dictionary<string, object> bank = new Dictionary<string, object>();
     var selectedArtist = Artist.Find(parameters.id);
     var artistTitles = selectedArtist.GetCds();
     bank.Add("artist", selectedArtist);
     bank.Add("title", artistTitles);
     return View["artist_title_form.cshtml", bank];
       };
       Get["/artist_title"] = _ =>
       {
     Cd newCd = newCd(Request.Form["cd-title"]);
     List<Cd> allcds = cd
       }
       Post["/view_title"] = _ =>
       {
     string artist = Request.Form["artist"];
     List<Artist> results = Artist.SearchArtist(artist);
     return View["view_title.cshtml", results];
       };
 }
예제 #3
0
파일: HomeModule.cs 프로젝트: ottoetc/cdapp
 public HomeModule()
 {
     Get["/"] = _ => {
     var cdList = Cd.GetAllCd();
     return View["index.cshtml", cdList];
       };
       Get["/new"] = _ => {
     return View["cd_form.cshtml"];
       };
       Post["/"] = _ => {
     var newCd = new Cd(Request.Form["cd-name"], Request.Form["artist-name"]);
     var cdList = Cd.GetAllCd();
     return View["index.cshtml", cdList];
       };
       Get["/searchbyartist"] = _ => {
     return View["searchbyartist.cshtml"];
       };
       Post["/searchbyartist"] = _ =>{
     var searchResult = Artist.Find(Request.Form["artist-name"]);
     return View["searchresult.cshtml", searchResult];
       };
 }
예제 #4
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["index.cshtml"]);
            };
            Get["/artists"] = _ => {
                var allArtists = Artist.GetAll();
                return(View["artists.cshtml", allArtists]);
            };
            Get["/artist_form"] = _ => {
                return(View["artist_form.cshtml"]);
            };
            Post["/artists"] = _ => {
                var newArtist  = new Artist(Request.Form["artist-name"]);
                var allArtists = Artist.GetAll();
                return(View["artists.cshtml", allArtists]);
            };
            Get["/artists/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedArtist = Artist.Find(parameters.id);
                var artistCds      = selectedArtist.GetCds();
                model.Add("artist", selectedArtist);
                model.Add("cds", artistCds);
                return(View["artist.cshtml", model]);
            };

            Post["/artists/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedArtist = Artist.Find(parameters.id);
                selectedArtist.AddCd(new Cd(Request.Form["cd-title"]));
                var artistCds = selectedArtist.GetCds();
                model.Add("artist", selectedArtist);
                model.Add("cds", artistCds);
                return(View["artist.cshtml", model]);
            };
            Get["/artists/{id}/cds/new"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Artist    selectedArtist          = Artist.Find(parameters.id);
                List <Cd> allCds = selectedArtist.GetCds();
                model.Add("artist", selectedArtist);
                model.Add("cds", allCds);
                return(View["artist_cds_form.cshtml", model]);
            };
            Post["/cds"] = _ => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                Artist    selectedArtist          = Artist.Find(Request.Form["artist-id"]);
                List <Cd> artistCds = selectedArtist.GetCds();
                string    cdTitle   = Request.Form["cd-title"];
                Cd        newCd     = new Cd(cdTitle);
                artistCds.Add(newCd);
                model.Add("cds", artistCds);
                model.Add("artist", selectedArtist);
                return(View["artist.cshtml", model]);
            };
            Get["/artist_cds_form/{id}"] = parameters => {
                Dictionary <string, object> model = new Dictionary <string, object>();
                var selectedArtist = Artist.Find(parameters.id);
                model.Add("artist", selectedArtist);
                return(View["artist_cds_form.cshtml", model]);
            };
        }
예제 #5
0
 public void AddCd(Cd cd)
 {
     _cds.Add(cd);
 }