public ActionResult ListBooks() { IEnumerable <Book> lib = manager.GetContext().Lib; List <BookForPage> books = new List <BookForPage>(); int number = 0; List <Book> oldBooks = lib.ToList(); foreach (var b in lib) { DBManager man2 = new DBManager(); BookForPage newBook = new BookForPage { Id = oldBooks[number].Id, Book_title = oldBooks[number].Book_title, Description = oldBooks[number].Short_description, Number_copies_on_hands = oldBooks[number].Number_copies - LibApp.GetNumberBookOnHands(oldBooks[number], man2.GetContext()) }; books.Add(newBook); ++number; } ViewBag.Lib = books; return(View()); }
public void Update() { var tableName = string.IsNullOrEmpty(Request.Params["table_name"]) ? "" : Request.Params["table_name"]; string message = LibApp.Update(tableName, this); Response.Redirect("/Home/WorkWithBD?table=" + tableName + "&message=" + message); }
public ActionResult Orders(string type, string message) { ViewBag.TableName = type == "buy" ? "buy" : "reading"; ViewBag.NamesList = new List <string> { "Название книги", "Имя заказавшего работника" }; ViewBag.Type = type; ViewBag.Table = LibApp.GetListOrders(type); return(View()); }
public ActionResult WorkWithBD(string table, string message, string mode) { ViewBag.NamesList = LibApp.GetListNamesTables(table); ViewBag.Message = message; ViewBag.Table = LibApp.GetTable(table); ViewBag.TableName = table; ViewBag.Context = manager.GetContext(); ViewBag.Mode = mode; return(View()); }
public ActionResult Read(string message) { ViewBag.Message = message; ViewBag.NamesList = new List <string> { "Название книги", "Краткое описание", "Количество свободных книг" }; ViewBag.Table = LibApp.GetListAvailableBooks(); return(View()); }
public void WorkWithBD() { var str = Request.Form["add_record"]; if (Request.Form["add_record"] == "Добавить") { var tableName = Request.Params["table"]; string message = LibApp.Insert(tableName, this); Response.Redirect("/Home/WorkWithBD?table=" + tableName + "&message=" + message); } }
public ActionResult Delete(string table, int Id, string returnPage) { if (returnPage == "WorkWithDB") { string message = LibApp.Delete(this, table, Id); Response.Redirect("/Home/WorkWithBD?table=" + table + "&message=" + message); } else if (returnPage == "Return") { DBManager man2 = new DBManager(); var t = man2.GetContext().IssuedBooks; var order = t.Find(Id); var book = manager.GetContext().Lib.Find(order.Id_book); UpdateHelper.FromBook(book.Id, book.Book_title, book.Short_description, book.Number_copies.ToString(), Convert.ToString(book.How_many_times + 1)); string message = LibApp.Delete(this, table, Id); Response.Redirect("/Home/Return?message=" + message); } return(View()); }
public ActionResult BooksOnHands() { IEnumerable <Book> lib = manager.GetContext().Lib; List <BookOnHands> books = new List <BookOnHands>(); int number = 0; List <Book> oldBooks = lib.ToList(); foreach (var b in lib) { DBManager man2 = new DBManager(); BookOnHands newBook = new BookOnHands { Book_title = oldBooks[number].Book_title, Number_copies_on_hands = LibApp.GetNumberBookOnHands(oldBooks[number], man2.GetContext()) }; books.Add(newBook); ++number; } ViewBag.Lib = books; return(View()); }
public ActionResult Return(string message) { ViewBag.Table = LibApp.GetListReturnBooks();//manager.GetContext().IssuedBooks; ViewBag.Message = message; return(View()); }
public ActionResult Update(string table, int Id) { ViewBag.TableName = table; ViewBag.Element = LibApp.GetTable(table).Find(Id); return(View()); }