Exemplo n.º 1
0
 public ReviewerRepository(BookDbContext bookDbContext)
 {
     _bookDbContext = bookDbContext;
 }
Exemplo n.º 2
0
 public BookRepository(BookDbContext bookDbContext)
 {
     _bookDbContext = bookDbContext;
 }
Exemplo n.º 3
0
 public ReviewerRepository(BookDbContext context)
 {
     _context = context;
 }
Exemplo n.º 4
0
 public BookFilterDropdownService(BookDbContext db)
 {
     _db = db;
 }
Exemplo n.º 5
0
 public ConfigSoftDelete(BookDbContext context)
     : base(context)
 {
     GetSoftDeleteValue = entity => entity.SoftDeleted;
     SetSoftDeleteValue = (entity, value) => entity.AlterSoftDelete(value);
 }
Exemplo n.º 6
0
 public List <Book> Books([Service] BookDbContext dbContext) => dbContext.Books.Include(x => x.Author).ToList();
Exemplo n.º 7
0
 public HomeController(ILogger <HomeController> logger, BookDbContext context)
 {
     _logger  = logger;
     _context = context;
 }
        public async Task <IActionResult> Index(SortFilterPageOptionsNoCount options, [FromServices] BookDbContext context)
        {
            var bookList = (await context.DapperBookListQueryAsync(options)).ToList();

            options.SetupRestOfDto(bookList.Count);

            SetupTraceInfo();

            return(View(new BookListNoCountCombinedDto(options, bookList)));
        }
Exemplo n.º 9
0
 public BooksController(BookDbContext bookContext)
 {
     _bookContext = bookContext;
 }
Exemplo n.º 10
0
 public AuthorRepository(BookDbContext _context)
 {
     contex = _context;
 }
Exemplo n.º 11
0
 public CreateModel(BookDbContext context)
 {
     _context = context;
 }
Exemplo n.º 12
0
 public ListUdfsBooksService(BookDbContext context)
 {
     _context = context;
 }
 public AuthorNameUpdatedHandlerAsync(BookDbContext sqlContext, IBookToCosmosBookService service)
 {
     _sqlContext = sqlContext;
     _service    = service;
 }
 public ListBooksCachedService(BookDbContext context)
 {
     _context = context;
 }
Exemplo n.º 15
0
        public Book GetBook()
        {
            var Db = new BookDbContext();

            return(null);
        }
Exemplo n.º 16
0
        public static void Main(string[] args)
        {
            #region Repository
            // using (var db = new BookDbContext())
            // {
            //     if (!db.Books.Any())
            //     {
            //         var book1 = new Book
            //         {
            //             BookId = 1,
            //             BookName = "Python In Action",
            //             Price = 1.1,
            //             Publisher = "China Publisher",
            //             AuthorId = 1
            //         };
            //         var book2 = new Book
            //         {
            //             BookId = 2,
            //             BookName = "C# In Action",
            //             Price = 2.2,
            //             Publisher = "TSingHua Publisher",
            //             AuthorId = 2
            //         };
            //         db.Books.AddRange(book1, book2);
            //         db.SaveChanges();
            //     }
            //     if (!db.Authors.Any())
            //     {
            //         var author1 = new Author
            //         {
            //             AuthorId = 1,
            //             Name = "Xi Yin",
            //             Age = 15
            //         };
            //         var author2 = new Author
            //         {
            //             AuthorId = 2,
            //             Name = "Xin Xin",
            //             Age = 18
            //         };
            //         db.Authors.AddRange(author1, author2);
            //         db.SaveChanges();
            //     }

            //     var books1 = db.Books
            //         .Include(p => p.Authors)
            //         .FirstOrDefault(p => p.BookId == 2);

            //     var books2 = db.Books
            //         .Include(p => p.Authors)
            //         .FirstOrDefault(p => p.BookId == 1);

            //     Console.WriteLine(books1.BookName + "\n" + books1.Price + "\n" +
            //     books1.Publisher + "\n" + books1.Authors.Name);

            //     Console.WriteLine(books2.BookName + "\n" + books2.Price + "\n" +
            //     books2.Publisher + "\n" + books2.Authors.Name);

            //     books1.BookName = "How to Spend spare time!";
            //     db.Books.Update(books1);
            //     db.SaveChanges();

            //     var author3 = db.Set<Author>().Find(1);
            //     Console.WriteLine(author3.Age);
            // }
            #endregion
            #region Generated Value
            using (var db = new BookDbContext()) {
                if (!db.Blogs.Any())
                {
                    var blog = new Blog {
                        Url = "Https://q.cnblogs.com",
                    };
                    var book = new Book {
                        BookId   = 1,
                        BookName = "111"
                    };

                    db.Blogs.AddRange(blog);
                    db.Books.AddRange(book);
                    db.SaveChanges();
                }
            }
            using (var db = new BookDbContext()) {
                var book = db.Books.Where(p => p.BookId == 1).FirstOrDefault();
                Console.WriteLine(book.BookName + book.BookId);
            }
            #endregion
        }
Exemplo n.º 17
0
 //By convention GetBook() will be recorded as book in the query field.
 public Book GetBook([Service] BookDbContext dbContext, int id) => dbContext.Books.FirstOrDefault(x => x.Id == id);
 public AuthorRepository(BookDbContext authorContext)
 {
     _authorContext = authorContext;
 }
Exemplo n.º 19
0
 public LanguageRepository(BookDbContext bookContext)
 {
     _bookContext = bookContext;
 }
Exemplo n.º 20
0
 public BookController(BookDbContext bookDbContext)
 {
     this.bookDbContext = bookDbContext;
 }
Exemplo n.º 21
0
        public static void SeedDataContext(this BookDbContext context)
        {
            var booksAuthors = new List <BookAuthor>()
            {
                new BookAuthor()
                {
                    Book = new Book()
                    {
                        Isbn           = "123",
                        Title          = "The Call Of The Wild",
                        DatePublished  = new DateTime(1903, 1, 1),
                        BookCategories = new List <BookCategory>()
                        {
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "Action"
                                }
                            }
                        },
                        Reviews = new List <Review>()
                        {
                            new Review {
                                Headline = "Awesome Book", ReviewText = "Reviewing Call of the Wild and it is awesome beyond words", Rating = 5,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "John", LastName = "Smith"
                                }
                            },
                            new Review {
                                Headline = "Terrible Book", ReviewText = "Reviewing Call of the Wild and it is terrrible book", Rating = 1,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "Peter", LastName = "Griffin"
                                }
                            },
                            new Review {
                                Headline = "Decent Book", ReviewText = "Not a bad read, I kind of liked it", Rating = 3,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "Paul", LastName = "Griffin"
                                }
                            }
                        }
                    },
                    Author = new Author()
                    {
                        FirstName = "Jack",
                        LastName  = "London",
                        Country   = new Country()
                        {
                            Name = "USA"
                        }
                    }
                },
                new BookAuthor()
                {
                    Book = new Book()
                    {
                        Isbn           = "1234",
                        Title          = "Winnetou",
                        DatePublished  = new DateTime(1878, 10, 1),
                        BookCategories = new List <BookCategory>()
                        {
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "Western"
                                }
                            }
                        },
                        Reviews = new List <Review>()
                        {
                            new Review {
                                Headline = "Awesome Western Book", ReviewText = "Reviewing Winnetou and it is awesome book", Rating = 4,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "Frank", LastName = "Gnocci"
                                }
                            }
                        }
                    },
                    Author = new Author()
                    {
                        FirstName = "Karl",
                        LastName  = "May",
                        Country   = new Country()
                        {
                            Name = "Germany"
                        }
                    }
                },
                new BookAuthor()
                {
                    Book = new Book()
                    {
                        Isbn           = "12345",
                        Title          = "Pavols Best Book",
                        DatePublished  = new DateTime(2019, 2, 2),
                        BookCategories = new List <BookCategory>()
                        {
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "Educational"
                                }
                            },
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "Computer Programming"
                                }
                            }
                        },
                        Reviews = new List <Review>()
                        {
                            new Review {
                                Headline = "Awesome Programming Book", ReviewText = "Reviewing Pavols Best Book and it is awesome beyond words", Rating = 5,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "Pavol2", LastName = "Almasi2"
                                }
                            }
                        }
                    },
                    Author = new Author()
                    {
                        FirstName = "Pavol",
                        LastName  = "Almasi",
                        Country   = new Country()
                        {
                            Name = "Slovakia"
                        }
                    }
                },
                new BookAuthor()
                {
                    Book = new Book()
                    {
                        Isbn           = "123456",
                        Title          = "Three Musketeers",
                        DatePublished  = new DateTime(2019, 2, 2),
                        BookCategories = new List <BookCategory>()
                        {
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "Adventure"
                                }
                            },
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "History"
                                }
                            }
                        }
                    },
                    Author = new Author()
                    {
                        FirstName = "Alexander",
                        LastName  = "Dumas",
                        Country   = new Country()
                        {
                            Name = "France"
                        }
                    }
                },
                new BookAuthor()
                {
                    Book = new Book()
                    {
                        Isbn           = "1234567",
                        Title          = "Big Romantic Book",
                        DatePublished  = new DateTime(1879, 3, 2),
                        BookCategories = new List <BookCategory>()
                        {
                            new BookCategory {
                                Category = new Category()
                                {
                                    Name = "Romance"
                                }
                            }
                        },
                        Reviews = new List <Review>()
                        {
                            new Review {
                                Headline = "Good Romantic Book", ReviewText = "This book made me cry a few times", Rating = 5,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "Allison", LastName = "Kutz"
                                }
                            },
                            new Review {
                                Headline = "Horrible Romantic Book", ReviewText = "My wife made me read it and I hated it", Rating = 1,
                                Reviewer = new Reviewer()
                                {
                                    FirstName = "Kyle", LastName = "Kutz"
                                }
                            }
                        }
                    },
                    Author = new Author()
                    {
                        FirstName = "Anita",
                        LastName  = "Powers",
                        Country   = new Country()
                        {
                            Name = "Canada"
                        }
                    }
                }
            };

            context.BookAuthors.AddRange(booksAuthors);
            context.SaveChanges();
        }
Exemplo n.º 22
0
 public Handler(BookDbContext context)
 {
     _context = context;
 }
Exemplo n.º 23
0
 public DefaultSettingsCreator(BookDbContext context)
 {
     _context = context;
 }
Exemplo n.º 24
0
 public UpsertModel(BookDbContext db)
 {
     _dbContext = db;
 }
Exemplo n.º 25
0
        public static void Initializer(BookDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.Authors.Any())
            {
                return;
            }

            var authors = new Author[]
            {
                new Author {
                    Name = "Armistead Maupin", BooksCount = 23
                },
                new Author {
                    Name = "David Talbot", BooksCount = 5
                },
                new Author {
                    Name = "Nathanael West", BooksCount = 22
                },
                new Author {
                    Name = "James Ellroy", BooksCount = 5
                },
                new Author {
                    Name = "John Steinbeck", BooksCount = 3
                }
            };

            foreach (var a in authors)
            {
                context.Authors.Add(a);
            }


            var books = new Book[]
            {
                new Book {
                    AuthorID = 1, Title = "Tales of the City", Genre = "Fictions", Price = 9.99m, Year = 1958, Publiser = "Amazon"
                },
                new Book {
                    AuthorID = 1, Title = "Of Mice and Men", Genre = "Novella", Price = 5.99m, Year = 1978, Publiser = "Atomic Drop Press"
                },
                new Book {
                    AuthorID = 1, Title = "Where I Was From", Genre = "Adventure", Price = 19.99m, Year = 2000, Publiser = "Musa Publishing"
                },
                new Book {
                    AuthorID = 1, Title = "We Tell Ourselves Stories in Order to Live", Genre = "Essay", Price = 12.99m, Year = 2005, Publiser = "Alfresco Press"
                },

                new Book {
                    AuthorID = 2, Title = "Blue Nights", Genre = "Memoire", Price = 19.99m, Year = 2011, Publiser = "Barking Rain Press"
                },
                new Book {
                    AuthorID = 2, Title = "Run, River", Genre = "Fictions", Price = 7.99m, Year = 2012, Publiser = "Arma Technologies"
                },
                new Book {
                    AuthorID = 2, Title = "Run, River", Genre = "Essay", Price = 9.99m, Year = 2001, Publiser = "Chances Press, LLC"
                },
                new Book {
                    AuthorID = 2, Title = "Get Out", Genre = "Horror", Price = 9.99m, Year = 2012, Publiser = "Kore Press"
                },

                new Book {
                    AuthorID = 3, Title = "My Sister's Keeper", Genre = "Thriller", Price = 12.99m, Year = 1998, Publiser = "Kore Press"
                },
                new Book {
                    AuthorID = 3, Title = "Gone Girl", Genre = "Fictions", Price = 9.99m, Year = 2005, Publiser = "Broadway Books"
                },
                new Book {
                    AuthorID = 3, Title = "The Chronicles of Narnia", Genre = "Fantastic", Price = 9.99m, Year = 2012, Publiser = "HarperCollins"
                },
                new Book {
                    AuthorID = 3, Title = "Assassin's Apprentice", Genre = "Fantastic", Price = 15.99m, Year = 2008, Publiser = "Robin Hobb"
                },

                new Book {
                    AuthorID = 4, Title = "Ender's Game", Genre = "Sci-Fi", Price = 19.99m, Year = 2000, Publiser = "Tor"
                },
                new Book {
                    AuthorID = 4, Title = "I, Robot", Genre = "Sci-Fi", Price = 9.99m, Year = 2004, Publiser = "Spectra"
                },
                new Book {
                    AuthorID = 4, Title = "Slaughterhouse-Five", Genre = "Fictions", Price = 9.99m, Year = 1999, Publiser = "Dial Press"
                },
                new Book {
                    AuthorID = 4, Title = "Pride and Prejudice", Genre = "Crime-Dram", Price = 9.99m, Year = 1988, Publiser = "Amazon"
                }
            };

            foreach (var b in books)
            {
                context.Books.Add(b);
            }


            var reviews = new Review[]
            {
                new Review {
                    BookId = 1, Rating = 4, UserName = "******", Body = "Best book i ever read"
                },
                new Review {
                    BookId = 1, Rating = 5, UserName = "******", Body = "Best book i ever read, i really recommend to anyone"
                },
                new Review {
                    BookId = 2, Rating = 4, UserName = "******", Body = "It was very confusing and at the sane time interesting"
                },
                new Review {
                    BookId = 6, Rating = 2, UserName = "******", Body = "It was boring but i lked the characters in the book"
                },

                new Review {
                    BookId = 5, Rating = 4, UserName = "******", Body = "I just loved ittttttt"
                },
                new Review {
                    BookId = 5, Rating = 5, UserName = "******", Body = "I would like to see the movie!!!#MakeIt"
                },
                new Review {
                    BookId = 2, Rating = 5, UserName = "******", Body = "I wish it were short but i enjoyed it"
                },
                new Review {
                    BookId = 2, Rating = 3, UserName = "******", Body = "This contains some information educative"
                },

                new Review {
                    BookId = 3, Rating = 4, UserName = "******", Body = "Best book i ever read"
                },
                new Review {
                    BookId = 3, Rating = 4, UserName = "******", Body = "Best book i ever read"
                },
                new Review {
                    BookId = 4, Rating = 4, UserName = "******", Body = "I can read again. Liked it"
                },
                new Review {
                    BookId = 8, Rating = 4, UserName = "******", Body = "Good"
                }
            };

            foreach (var r in reviews)
            {
                context.Reviews.Add(r);
            }


            context.SaveChanges();
        }
Exemplo n.º 26
0
 public List2Model(BookDbContext context)
 {
     _context = context;
 }
Exemplo n.º 27
0
 public AuthorsController(BookDbContext db)
 {
     _db = db;
 }
Exemplo n.º 28
0
 public AuthorRepository(BookDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 29
0
 public SubscriptionController(IUserService userservices, SignInManager <ApplicationUser> signInManager, BookDbContext db)
 {
     _userService = userservices;
     _signManager = signInManager;
     _db          = db;
 }
Exemplo n.º 30
0
 public BookRepositoryEF(BookDbContext bookDbContext)
 {
     BookDbContext = bookDbContext;
 }