// GET: BooksStocks public ActionResult Index() { List <Book> bk = new List <Book>(); bk = db.Books.ToList(); List <BooksNeed> bkn = db.BooksNeeds.ToList(); List <SchoolsCategory> sc = db.SchoolsCategorys.ToList(); List <BooksCategory> _booksCategory = db.BooksCategorys.ToList(); List <BooksStock> bstk = db.BooksStocks.ToList(); List <ShoolBooksStocksViewModel> wmlist = new List <ShoolBooksStocksViewModel>(); foreach (var item in bstk) {// bu model foreach içinde eklenmeli ShoolBooksStocksViewModel wm = new ShoolBooksStocksViewModel(); wm.Id = item.Id; wm.DemandDate = item.DemandDate; wm.Name = bk.FirstOrDefault(x => x.Id == item.BookId).Name; //wm.Name = item.Name; wm.Class = bk.FirstOrDefault(x => x.Id == item.BookId).Class; //wm.BookCategory = bk.FirstOrDefault(x => x.Id == item.BookId).BookType; wm.BookCount = item.BookCount; //bkn.FirstOrDefault(x => x.Id == item.Id).BookCount; /* wm.SchoolsCategory =*/ /*sc.FirstOrDefault(x => x.Id == item.Id).Category;*/ wm.SchoolsCategory = db.Books.FirstOrDefault(x => x.Id == item.BookId).BookType; wmlist.Add(wm); } return(View(wmlist)); }
// GET: BooksStocks public ActionResult Index2() { List <Book> bk = new List <Book>(); bk = db.Books.ToList(); List <BooksNeed> bkn = db.BooksNeeds.ToList(); List <SchoolsCategory> sc = db.SchoolsCategorys.ToList(); List <BooksCategory> _booksCategory = db.BooksCategorys.ToList(); List <BooksStock> bstk = new List <BooksStock>(); bstk = db.BooksStocks.ToList(); List <ShoolBooksStocksViewModel> wmlist = new List <ShoolBooksStocksViewModel>(); foreach (var item in bstk) {// bu model foreach içinde eklenmeli ShoolBooksStocksViewModel wm = new ShoolBooksStocksViewModel(); wm.Id = item.Id; wm.DemandDate = item.DemandDate; wm.Name = bk.FirstOrDefault(x => x.Id == item.BookId).Name; //wm.Name = item.Name; wm.Class = bk.FirstOrDefault(x => x.Id == item.BookId).Class; //wm.BookCategory = bk.FirstOrDefault(x => x.Id == item.BookId).BookType; wm.BookCount = item.BookCount; //bkn.FirstOrDefault(x => x.Id == item.Id).BookCount; /* wm.SchoolsCategory =*/ /*sc.FirstOrDefault(x => x.Id == item.Id).Category;*/ wm.SchoolsCategory = db.Books.FirstOrDefault(x => x.Id == item.BookId).BookType; wmlist.Add(wm); } string schoolType = (Session["SchoolType"]).ToString(); if (schoolType != "İLÇE MİLLİ EĞİTİM") { wmlist.Where(x => x.SchoolsCategory.ToString() == schoolType); //List<string> BookClassList = db.SchoolClasses.Where(x => x.Category == schooltype).Select(x => x.Class).Distinct().ToList(); // ViewBag.BookClassListViewBag = BookClassList; } //else //{ // wmlist; // //List<string> BookClassList = db.Books.Select(x => x.Class).ToList(); // //List<string> BookClassList = db.SchoolClasses.Where(x => x.Category == schooltype).Select(x => x.Class).Distinct().ToList(); // // ViewBag.BookClassListViewBag = BookClassList; //} //return View(wmlist.Where(x => x.SchoolsCategory.ToString() == schoolType)); return(View(wmlist)); }