Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            var spec        = new LibraryBranchesWithPatronAndAssetsSpecification();
            var allBranches = await _branch.ListAsync(spec);

            var branchModels = allBranches
                               .Select(branch => new BranchDetailModel
            {
                Id              = branch.Id,
                BranchName      = branch.Name,
                NumberOfAssets  = _branch.GetAssetCount(branch.Id),
                NumberOfPatrons = _branch.GetPatronCount(branch.Id),
                IsOpen          = _branch.IsBranchOpen(branch.Id)
            });

            var model = new BranchIndexModel()
            {
                Branches = branchModels
            };

            return(View(model));
        }