示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
 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());
 }
示例#4
0
 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());
 }
示例#5
0
        public ActionResult Read(string message)
        {
            ViewBag.Message   = message;
            ViewBag.NamesList = new List <string> {
                "Название книги", "Краткое описание", "Количество свободных книг"
            };
            ViewBag.Table = LibApp.GetListAvailableBooks();

            return(View());
        }
示例#6
0
        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);
            }
        }
示例#7
0
 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());
 }
示例#8
0
        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());
        }
示例#9
0
 public ActionResult Return(string message)
 {
     ViewBag.Table   = LibApp.GetListReturnBooks();//manager.GetContext().IssuedBooks;
     ViewBag.Message = message;
     return(View());
 }
示例#10
0
 public ActionResult Update(string table, int Id)
 {
     ViewBag.TableName = table;
     ViewBag.Element   = LibApp.GetTable(table).Find(Id);
     return(View());
 }