Exemple #1
0
 public IEnumerable <GenreVM> GetAll()
 {
     using (context)
     {
         try
         {
             //SELECT * FROM BOOKS ORDER BY ID DESC
             var genres   = context.Genres.ToList().OrderByDescending(x => x.ID);
             var genresVm = genres.Select(x => toViewModel.Genre(x));
             return(genresVm);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Exemple #2
0
 public IEnumerable <GenreVM> GetAll()
 {
     using (context)
     {
         using (var dbTransaction = context.Database.BeginTransaction())
         {
             try
             {
                 // gets all genres record and order from highest to lowest
                 var genres   = context.Genres.ToList().OrderByDescending(x => x.ID);
                 var genresVm = genres.Select(x => toViewModel.Genre(x));
                 return(genresVm);
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }