public IEnumerable<Book> GetAllBooks() { using (var db = new BookContext()) { return db.Books.ToList(); } }
public Book GetBookById(int Id) { Book _objBook = new Book(); using (var db = new BookContext()) { _objBook = db.Books.Find(Id); } return _objBook; }
public bool Add(Book book) { Boolean res = false; using (var db = new BookContext()) { db.Books.Add(book); db.SaveChanges(); res = true; } return res; }
public bool Edit(Book book) { Boolean res = false; using (var db = new BookContext()) { db.Entry(book).State = System.Data.EntityState.Modified; db.SaveChanges(); res = true; } return res; }
public BookController() { ViewBag.ActivePageBook = "active"; _db = new BookContext(); }
public BookService(BookContext context, IWebHostEnvironment environment, IMapper mapper) { _context = context; _environment = environment; _mapper = mapper; }
public PublisherService(BookContext bookContext) { // TODO: keep a reference to the AuthorContext in _AuthorContext _bookContext = bookContext; }
public BookRepository(BookContext database) { this.database = database; }
public BookService(BookContext bookContext) { // TODO: keep a reference to the BookContext in _bookContext _bookContext = bookContext; }
public AwardsService(BookContext bookContext) { _bookContext = bookContext; }
public BookRepositprie(BookContext context) { _context = context; }
public UserController(BookContext bookcontext, IMemoryCache memoryCache) : base(bookcontext, memoryCache) { _bookcontext = bookcontext; }
/*public BookManeger() * { * context = new Exampl(); * } */ public BookManeger(BookContext context) { this.context = context; }
/// <summary> /// Create a new instance of the class with an existing context. /// </summary> public BookService(BookContext bookContext) { this.context = bookContext; }
/// <summary> /// Create a new instance of the class with a new context. /// </summary> public BookService() { this.context = new BookContext(); }
public AuthorsController(BookContext context) { _context = context; }
public BookController() { _db = new BookContext(); }
public GenreRepository(BookContext context) : base(context) { }
protected override void Seed(BookContext context) { }
public BooksController(BookContext context) { this.context = context; }
public HomeController(BookContext context) { _contextInject = context; }
public PublisherService(BookContext bookContext) { _bookContext = bookContext; }
public BooksController(BookContext context) { _context = context; }
public BookService(BookContext context) { _context = context; }
public FormatRepository(BookContext database) { this.database = database; }
public BookUoW(string ConntectionString) { _bookContext = new BookContext(ConntectionString); }
public BookService(BookContext bookContext) { _bookContext = bookContext; }
public GanreRepository() { db = new BookContext(); }
private async Task LoadBook() { BookContext bc = new BookContext(); this.Book = await bc.Load(); TopChapters = new ObservableCollection<Chapter>(); var filterResult = this.Book.Chapters.Take(10); foreach (var chapter in filterResult) { TopChapters.Add(chapter); } ChapterGroup group=null; for (int i = 0; i < this.Book.Chapters.Count; i++) { if (group==null) { group = new ChapterGroup() { Key = (i + 1).ToString() + "~" + (i+chapterGroupSize).ToString() }; ChapterGroups.Add(group); } group.Chapters.Add(this.Book.Chapters[i]); if (((i+1) % chapterGroupSize)==0) { group = null; } } }
static List <Models.Sach> GetListNoiBat() { var db = new BookContext(); //lấy hết sách chưa xoá List <Sach> listSach = db.Sach.Where(x => x.flag == false).ToList(); //list sách kết quả trả về List <Sach> listSachResult = new List <Sach>(); //Ma trận 2 chiều để lấy sách và số lượng sách trong bill //Có dạng (ví dụ): // 0 1 2 3 4 5 6 7 8 // 0 s0 s1 s2 s3 s4 s5 s6 s7 s8 (MaSach) // 1 12 8 56 22 1 20 3 9 10 (SoLuong sách trong bill) int[,] saches = new int[listSach.Count, 2]; var listCTHD = db.ChiTietHoaDon.Where(x => x.flag == false).ToList(); //lấy mã sách bỏ vào hàng MaSach //cho SoLuong ban đầu là 0 //Có dạng: // 0 1 2 3 4 5 6 7 8 // 0 s0 s1 s2 s3 s4 s5 s6 s7 s8 (MaSach) // 1 0 0 0 0 0 0 0 0 0 (SoLuong sách trong bill) int i = 0; foreach (var item in listSach) { saches[i, 0] = item.MaSach; saches[i, 1] = 0; i += 1; } //duyệt chi tiết hoá đơn để lấy số lượng //Có dạng (ví dụ): // 0 1 2 3 4 5 6 7 8 // 0 s0 s1 s2 s3 s4 s5 s6 s7 s8 (MaSach) // 1 12 8 56 22 1 20 3 9 10 (SoLuong sách trong bill) if (listCTHD.Count() != 0) { for (int j = 0; j < listSach.Count; j++) { foreach (var item in listCTHD) { if (item.MaSach == saches[j, 0]) { saches[j, 1] = saches[j, 1] + 1; } } } } //sắp xếp số lại mảng theo chiều giảm dần của số lượng //Có dạng (ví dụ): // 0 1 2 3 4 5 6 7 8 // 0 s0 s1 s2 s3 s4 s5 s6 s7 s8 (MaSach) // 1 33 28 26 22 19 15 9 5 1 (SoLuong sách trong bill) var a = saches; for (int j = 0; j < saches.GetLength(0) - 1; j++) { if (saches[j, 1] < saches[j + 1, 1]) { //đảo MaSach saches[j, 0] += saches[j + 1, 0]; saches[j + 1, 0] = saches[j, 0] - saches[j + 1, 0]; saches[j, 0] = saches[j, 0] - saches[j + 1, 0]; //đảo SoLuong saches[j, 1] += saches[j + 1, 1]; saches[j + 1, 1] = saches[j, 1] - saches[j + 1, 1]; saches[j, 1] = saches[j, 0] - saches[j + 1, 1]; } } for (int j = 0; j < saches.GetLength(0); j++) { listSachResult.Add(db.Sach.Find(saches[j, 0])); } return(listSachResult); }