public ActionResult BookDetails(int id) { CoolBooksEntities dc = new CoolBooksEntities(); Books books = dc.Books.Single(boo => boo.Id == id); return(View(books)); }
IEnumerable <SearchViewModel> GetAllBooks() { using (CoolBooksEntities db = new CoolBooksEntities()) { List <Books> booksList = db.Books.ToList(); SearchViewModel searchVm = new SearchViewModel(); List <SearchViewModel> searchVmList = booksList.Select(x => new SearchViewModel { Title = x.Title, ISBN = x.ISBN, AuthorId = x.AuthorId, AlternativeTitle = x.AlternativeTitle, Created = x.Created, Description = x.Description, FirstName = x.Authors.FirstName, GenreId = x.GenreId, Id = x.Id, ImagePath = x.ImagePath, ImageUpload = x.ImageUpload, IsDeleted = x.IsDeleted, LastName = x.Authors.LastName, Name = x.Genres.Name, Part = x.Part, PublishDate = x.PublishDate, UserId = x.UserId }).ToList(); return(searchVmList); } }