Example #1
0
 public static List <Title> SearchForTitles(string searchText)
 {
     using (var ctx = new BooksEntities1())
     {
         List <Title> titleSearch = ctx.Titles.Where(t => t.Title1.Contains(searchText)).ToList();
         return(titleSearch);
     }
 }
Example #2
0
 private void PopupateSearchAuthorsResultGridView()
 {
     using (var ctx = new BooksEntities1())
     {
         var authorsQuery = MyHelpers.SearchForAnAuthor(txtAuthorSearchText.Text);
         authorsResultGridView.DataSource = authorsQuery;
         authorsResultGridView.DataBind();
     }
 }
Example #3
0
 public static List <Author> SearchForAnAuthor(string searchText)
 {
     using (var ctx = new BooksEntities1())
     {
         List <Author> authorSearch =
             ctx.Authors.Where(a => a.FirstName.Contains(searchText) || a.LastName.Contains(searchText)).ToList();
         return(authorSearch);
     }
 }
Example #4
0
        public static List <Title> PopulateGridviewWithBooksFromASelectedAuthor(string id)
        {
            using (var ctx = new BooksEntities1())
            {
                ctx.Authors.Load();
                var populateGridviewWithBooks = ctx.Authors.Local.Where(a => a.AuthorID == Convert.ToInt32(id)).First();

                var bookQuery = populateGridviewWithBooks.Titles.OrderBy(t => t.Title1).ToList();
                return(bookQuery);
            }
        }
Example #5
0
        public static Author AddAuthor(string firstName, string lastName, string country)
        {
            using (var ctx = new BooksEntities1())
            {
                Author newAuthor = new Author();
                newAuthor.FirstName          = firstName;
                newAuthor.LastName           = lastName;
                newAuthor.CountryOfResidence = country;

                ctx.Authors.Add(newAuthor);
                ctx.SaveChanges();
                return(newAuthor);
            }
        }
        private void   LoadDropDownMenu()
        {
            //Todo: Get all authors and bind them to the dropdown menu
            using (var ctx = new BooksEntities1())
            {
                ctx.Authors.Load();

                var authorsQuery = ctx.Authors.Local.OrderBy(a => a.LastName).ThenBy(a => a.FirstName).
                                   Select(a => new
                {
                    Name = a.LastName + "," + a.FirstName, a.AuthorID
                });

                authorsDropDownList.DataValueField = "AuthorID";
                authorsDropDownList.DataTextField  = "Name";
                authorsDropDownList.DataSource     = authorsQuery;
                authorsDropDownList.DataBind();
            }
        }