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]; }; }
public bool IsArtist(CD CurrentCD) { string MyName = CurrentCD.GetArtist(); if (MyName == _name) { return true; } else { return false; } }
public HomeModule() { Get["/"] = _ => View["index.cshtml"]; Post["/viewArtist"] = _ => { Artist newArtist = new Artist(Request.Form["artistInput"]); List<Artist> listArtist = Artist.GetAll(); return View["viewArtist.cshtml", listArtist]; }; Get["/add_cd/{id}"] = parameters => { Dictionary<string, object> y = new Dictionary<string, object> (); var selectedArtist = Artist.Find(parameters.id); var artistCD = selectedArtist.GetCDS(); y.Add("selectedArtist",selectedArtist); y.Add("cdList",artistCD); return View["add_cd.cshtml", y]; }; // Post["/add_cd/{id}/new"] = parameters => // { // Dictionary<string, object> y = new Dictionary<string, object> (); // var selectedArtist = Artist.Find(parameters.id); // var allCDS = selectedArtist.GetCDS(); // y.Add("selectedArtist",selectedArtist); // y.Add("cdList",selectedArtist); // return View["add_cd.cshtml", y]; // }; Post["/add_cd/{id}/new"] = parameters => { Dictionary<string, object> y = new Dictionary<string, object> (); var selectedArtist = Artist.Find(parameters.id); List<CD> artistCD = selectedArtist.GetCDS(); var newCd = new CD(Request.Form["cdInput"]); selectedArtist.Save(newCd); y.Add("Artist", selectedArtist); y.Add("cdList", artistCD); return View["add_cd.cshtml", y]; }; }
public void AddArtistCD(CD cd) { _CDs.Add(cd); }
public void Save(CD example) { _cdList.Add(example); }