public static IList <AlbumSummary> GetAlbumSummariesByGenres(int GenreId) { //title artist price List <AlbumSummary> Albumsum = new List <AlbumSummary>(); SqlConnection connection = MusicStoreDB.GetConnection(); connection.Open(); string query = @"SELECT ArtistId, Price, Title FROM Album WHERE GenreId = @GenreId"; SqlCommand cmd = new SqlCommand(query, connection); cmd.Parameters.AddWithValue("@GenreId", GenreId); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { int ArtistId = (int)reader["ArtistId"]; double Price = Convert.ToDouble(reader["Price"]); string Title = (string)reader["Title"]; Albumsum.Add(new AlbumSummary() { Artist = ArtistRepository.GetArtistNameById(ArtistId), Price = Convert.ToString(Price) + " $", Title = Title }); } reader.Close(); connection.Close(); return(Albumsum); }
public ActionResult Search(String q) { MusicStoreDB storeDB = new MusicStoreDB(); var albums = storeDB.Albums .Include("Artist") .Where(a => a.Title.Contains(q) || q == null) .Take(10); return(View(albums)); }
public MoviesController(MusicStoreDB context) { _context = context; }
public ArtistsController(MusicStoreDB context) { _context = context; }
public AlbumsController(MusicStoreDB context) { _context = context; }
public StoreManagerController(MusicStoreDB context) { _context = context; }
// DELETE api/<controller>/5 public HttpResponseMessage Delete(int id) { MusicStoreDB.Albums.Remove(MusicStoreDB.Albums.FirstOrDefault(x => x.AlbumId == id)); return(ToJson(MusicStoreDB.SaveChanges())); }
// PUT api/<controller>/5 public HttpResponseMessage Put(int id, [FromBody] Album value) { MusicStoreDB.Entry(value).State = EntityState.Modified; return(ToJson(MusicStoreDB.SaveChanges())); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] Album value) { MusicStoreDB.Albums.Add(value); return(ToJson(MusicStoreDB.SaveChanges())); }