Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. static void Main()
  2.         {
  3.             using (var db = new BookShopContext())
  4.             {
  5.                 DbInitializer.ResetDatabase(db);
  6.  
  7.                 string command = Console.ReadLine().ToLower();
  8.  
  9.                 GetBooksByAgeRestriction(db, command);
  10.             }
  11.         }
  12.         public static string GetBooksByAgeRestriction(BookShopContext context, string command)
  13.         {
  14.             //string currentEnum = Enum.Parse(typeof(AgeRestriction), command, true).ToString();
  15.  
  16.             var books = context.Books
  17.                 .Where(x => x.AgeRestriction.ToString().ToLower().Equals(command))
  18.                 .OrderBy(x => x.Title)
  19.                 .ToList();
  20.            
  21.  
  22.             return string.Join(Environment.NewLine, books);
  23.  
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement