Exemple #1
0
        public ActionResult ReturnBook(string borrowerId, string bookIsbn)
        {
            // Check and see if overdue
            var checkOverdue = Overdue.Details(_context, borrowerId, bookIsbn);
            // Get borrowers details
            var borrow = _context.Borrows.Single(b => b.BorrowerId == borrowerId && b.Isbn == bookIsbn);


            if (checkOverdue.IsOverdue)
            {
                var overdue = new OverdueViewModel {
                    Borrow = borrow, OverdueDetails = checkOverdue
                };
                return(View("ReturnBook", overdue));
            }

            // Set the return date and flag the book as returned.
            borrow.ReturnDate = DateTime.Now;
            borrow.IsReturned = true;

            var book = _context.Books.Single(b => b.Isbn == bookIsbn);

            // Add the number of books in stock.
            book.NumberInStock++;

            _context.SaveChanges();

            // Initialize the Lending List
            var processBorrowers = new ProcessLendingViewModel(_context);

            ViewBag.Borrowers = _context.Borrows.Where(b => b.IsReturned == false).ToList().Count();
            return(View("Index", processBorrowers.GetLendingDetails()));
        }
Exemple #2
0
        public ActionResult OverdueReturnBook(OverdueViewModel model)
        {
            var processBorrowers = new ProcessLendingViewModel(_context);


            if (model.AlreadyPaid)
            {
                var book   = _context.Books.Single(b => b.Isbn == model.Borrow.Isbn);
                var borrow = _context.Borrows.Single(b => b.Id == model.Borrow.Id);

                // Set the return date and flag the book as returned.
                borrow.ReturnDate = DateTime.Now;
                borrow.IsReturned = true;

                // Add the number of books in stock.
                book.NumberInStock++;

                _context.SaveChanges();

                // Initialize the Lending List
                ViewBag.Borrowers = _context.Borrows.Where(b => b.IsReturned == false).ToList().Count();

                return(View("Index", processBorrowers.GetLendingDetails()));
            }

            // Initialize the Lending List
            ViewBag.Borrowers = _context.Borrows.Where(b => b.IsReturned == false).ToList().Count();
            return(View("Index", processBorrowers.GetLendingDetails()));
        }
 public MainWindowViewModel(string userID)
 {
     _bussiness = new MainWindowBussiness(userID);
     Teaching   = new TeachingManagementViewModel(_bussiness.Teaching);
     Calling    = new NameCallingManagementViewModel(_bussiness.Calling);
     Payment    = new PaymentViewModel(_bussiness.Payment);
     Overdue    = new OverdueViewModel(_bussiness.Overdue);
     Statistic  = new StatisticViewModel(_bussiness.Statistic);
     Setting    = new UserSettingViewModel(_bussiness.UserSetting);
     MainFunc   = 0;
 }
        public IActionResult Overdue()
        {
            var ctData = _api.GetCTransformersOverdue();
            var vtData = _api.GetVTransformersOverdue();
            var emData = _api.GetElectricsOverdue();

            var model = new OverdueViewModel()
            {
                CurrentTransformers = ctData,
                VoltageTransformers = vtData,
                ElectricityMeters   = emData
            };

            return(View(model));
        }