public ActionResult Create(string cdTitle) { CD newCD = new CD(cdTitle); List <CD> allCDs = CD.GetAll(); return(View("CDDetails", allCDs)); }
public ActionResult Index() { List <CD> allCds = CD.GetAll(); //Makes Index_HasCorrectModelType_CDList() pass return(View(allCds)); //return View(0); //Makes Index_HasCorrectModelType_CDList() fail }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml", CD.GetAll()]); }; Get["/cds-new"] = _ => { return(View["cd_form.cshtml"]); }; Post["/cds"] = _ => { var newCD = new CD(Request.Form["CD-name"], Request.Form["CD-artist"]); var allCDs = CD.GetAll(); return(View["index.cshtml", allCDs]); }; Post["/artist-search"] = _ => { Dictionary <string, object> model = new Dictionary <string, object> (); var searchArtist = (Request.Form["search-artist"]); var matchList = Artist.matchArtist(searchArtist, CD.GetAll()); model.Add("artist", searchArtist); model.Add("list", matchList); return(View["artist_result.cshtml", model]); }; Get["/search-artist"] = _ => { return(View["search_by_artist.cshtml"]); }; }
public void GetAll_ReturnsEmptyList_CDList() { List <CD> newCD = new List <CD> { }; List <CD> result = CD.GetAll(); CollectionAssert.AreEqual(newCD, result); }
public void GetAll_ReturnsCD_CDList() { CD newCD1 = new CD("test"); CD newCD2 = new CD("test2"); List <CD> newList = new List <CD> { newCD1, newCD2 }; List <CD> result = CD.GetAll(); CollectionAssert.AreEqual(newList, result); }
public void GetAll_ReturnsAllCategoryObjects_CategoryList() { //Arrange string name01 = "Work"; string name02 = "School"; CD newCD1 = new CD(name01); CD newCD2 = new CD(name02); List <CD> newList = new List <CD> { newCD1, newCD2 }; //Act List <CD> result = CD.GetAll(); //Assert CollectionAssert.AreEqual(newList, result); }
public HomeModule() { Get["/"] = _ => { List <CD> allCDs = CD.GetAll(); return(View["index.cshtml", allCDs]); }; Post["/"] = _ => { string artist = Request.Form["artist-name"]; string albumTitle = Request.Form["album-title"]; if (artist != "" & albumTitle != "") { CD newCD = new CD(artist, albumTitle); List <CD> allCDs = CD.GetAll(); return(View["index.cshtml", allCDs]); } else { return(View["new_cd_form.cshtml"]); } }; Get["/CD/new"] = _ => { return(View["new_cd_form.cshtml"]); }; Get["/CD/{id}"] = parameters => { return(View["album.cshtml", CD.Find(int.Parse(parameters.id))]); }; Get["/CD/search"] = _ => { return(View["search_by_artist.cshtml"]); }; Post["/CD/search_results"] = _ => { string searchArtistName = Request.Form["artist-name"]; List <Artist> matchingArtists = Artist.GetMatchingArtists(searchArtistName); return(View["search_results.cshtml", matchingArtists]); }; }
public HomeModule() { Get["/"] = _ => { List <CD> allCds = CD.GetAll(); return(View["index.cshtml", allCds]); }; Get["/cds/new"] = _ => { return(View["cds_form.cshtml"]); }; Post["/addCD"] = _ => { var newCD = new CD(Request.Form["artist-name"], Request.Form["album-name"], Request.Form["price"]); List <CD> allCds = CD.GetAll(); return(View["index.cshtml", allCds]); }; Get["/cds/search"] = _ => { return(View["search_form.cshtml"]); }; Post["/cdsearch"] = _ => { string searchinput = Request.Form["match"]; List <CD> returnCds = new List <CD> { }; List <CD> allCds = CD.GetAll(); foreach (CD album in allCds) { if (album.SearchArtist(searchinput)) { returnCds.Add(album); } } return(View["search_results.cshtml", returnCds]); }; Get["/album/{id}"] = parameters => { // System.Console.WriteLine(parameters.id); List <CD> allCds = CD.GetAll(); CD album = CD.Find(parameters.id); return(View["/cd_detail.cshtml", album]); }; }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/add_cd"] = _ => { return(View["add_cd.cshtml"]); }; Post["/view_cds"] = _ => { var newCD = new CD(Request.Form["artist"], Request.Form["album"]); var allCDs = CD.GetAll(); allCDs.Sort((cd1, cd2) => cd1.GetArtist().CompareTo(cd2.GetArtist())); return(View["view_cds.cshtml", allCDs]); }; Get["/view_cds"] = _ => { var allCDs = CD.GetAll(); return(View["/view_cds.cshtml", allCDs]); }; Get["/search"] = _ => { return(View["search_by_artist.cshtml"]); }; Post["/result"] = _ => { List <string> result = new List <string> { }; string searchTerm = Request.Form["searchName"]; var allCDs = CD.GetAll(); foreach (CD cd in allCDs) { if (cd.GetArtist().ToLower().Contains(searchTerm.ToLower())) { result.Add("Artist: " + cd.GetArtist()); result.Add("Album: " + cd.GetAlbum()); } } return(View["search_result.cshtml", result]); }; }
public ActionResult Index() { List <CD> allCDs = CD.GetAll(); return(View(allCDs)); }
public ActionResult Index() { return(View(CD.GetAll())); }