예제 #1
0
        public IActionResult Index()
        {
            // create home view model
            var homeVM = new HomeViewModel()
            {
                AuthorCount    = _authorRepository.Count(x => true),
                CustomerCount  = _customerRepository.Count(x => true),
                MusicCount     = _musicRepository.Count(x => true),
                LendMusicCount = _musicRepository.Count(x => x.Borrower != null)
            };

            // call view
            return(View(homeVM));
        }
        public IActionResult List()
        {
            var customerVM = new List <CustomerViewModel>();

            var customers = _customerRepository.GetAll();

            if (customers.Count() == 0)
            {
                return(View("Empty"));
            }

            foreach (var customer in customers)
            {
                customerVM.Add(new CustomerViewModel
                {
                    Customer   = customer,
                    MusicCount = _musicRepository.Count(x => x.BorrowerID == customer.CustomerID)
                });
            }
            return(View(customerVM));
        }