Ejemplo n.º 1
0
        public HomeModule()

        {
            Get["/"] = _ => {
                var allCDs = CD.GetAllCDs();
                return(View["index.cshtml", allCDs]);
            };
// view the mainpage, taking all the CDs as model
            Get["/cd/new"] = _ => {
                return(View["addCD.cshtml"]);
            };
//if you get CD/new, take to add CD form//
            Post["/cdAdded"] = _ => {
                var newCD     = new CD(Request.Form["cd-title"], Request.Form["cd-artist"], Request.Form["cd-year"], Request.Form["cd-cover"]);
                var newArtist = new Artist(Request.Form["cd-artist"]);
                newArtist.AddArtistCD(newCD);
                return(View["cdAdded.cshtml", newCD]);
            };

            Get["/searchbyartist"] = _ => {
                return(View["searchByArtist.cshtml"]);
            };

            Post["/searchresults"] = _ => {
                var       selectedArtist = Artist.Find(Request.Form["artist-name"]);
                List <CD> resultCDs      = selectedArtist.GetAllArtistsCDs();
                return(View["searchResults.cshtml", resultCDs]);
            };
        }
Ejemplo n.º 2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         var allCDs = CD.GetAllCDs();
         return(View["index.cshtml", allCDs]);
     };
     Get["/cd/new"] = _ => {
         return(View["add_cd_form.cshtml"]);
     };
     Get["/artist_search"] = _ => {
         return(View["artist_search_form.cshtml"]);
     };
     Post["/"] = _ => {
         var newCD  = new CD(Request.Form["cd-name"], Request.Form["artist-name"]);
         var allCDs = CD.GetAllCDs();
         return(View["index.cshtml", allCDs]);
     };
     Post["/artist_cds"] = _ => {
         var allCDs = CD.GetAllCDs();
         if (Request.Form["artist-id"] == "" || allCDs.Count < 1)
         {
             return(View["not_found.cshtml"]);
         }
         var SearchedArtist = Request.Form["artist-id"];
         var returnedList   = CD.SearchForArtist(SearchedArtist);
         return(View["Artist_CDs.cshtml", returnedList]);
     };
 }
Ejemplo n.º 3
0
        public List <CD> GetAllArtistsCDs()
        {
            List <CD> CDs     = CD.GetAllCDs();
            List <CD> results = new List <CD> {
            };

            foreach (var CD in CDs)
            {
                if (this.IsArtist(CD))
                {
                    results.Add(CD);
                }
            }
            return(results);
        }