示例#1
0
        public IActionResult Index()
        {
            var branches = _branch.GetAll().Select(x => new BranchDetailViewModel()
            {
                Id     = x.Id,
                Name   = x.Name,
                IsOpen = _branch.IsBranchOpen(x.Id),
                //Asynchronous operations used in a blocking manner below
                NumberOfAssets  = _branch.GetAssetsAsync(x.Id).Result.Count(),
                NumberOfPatrons = _branch.GetPatronsAsync(x.Id).Result.Count()
            });

            var model = new BranchIndexViewModel()
            {
                Branches = branches
            };

            return(View(model));
        }