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);
        }
Example #2
0
        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));
        }
Example #3
0
 public MoviesController(MusicStoreDB context)
 {
     _context = context;
 }
Example #4
0
 public ArtistsController(MusicStoreDB context)
 {
     _context = context;
 }
Example #5
0
 public AlbumsController(MusicStoreDB context)
 {
     _context = context;
 }
Example #6
0
 public StoreManagerController(MusicStoreDB context)
 {
     _context = context;
 }
Example #7
0
 // DELETE api/<controller>/5
 public HttpResponseMessage Delete(int id)
 {
     MusicStoreDB.Albums.Remove(MusicStoreDB.Albums.FirstOrDefault(x => x.AlbumId == id));
     return(ToJson(MusicStoreDB.SaveChanges()));
 }
Example #8
0
 // PUT api/<controller>/5
 public HttpResponseMessage Put(int id, [FromBody] Album value)
 {
     MusicStoreDB.Entry(value).State = EntityState.Modified;
     return(ToJson(MusicStoreDB.SaveChanges()));
 }
Example #9
0
 // POST api/<controller>
 public HttpResponseMessage Post([FromBody] Album value)
 {
     MusicStoreDB.Albums.Add(value);
     return(ToJson(MusicStoreDB.SaveChanges()));
 }