public IActionResult Index() { var branches = _branch.GetAll().Select(a => new BranchDetailModel { Id = a.Id, BranchName = a.Name, isOpen = _branch.isBranchOpen(a.Id), NumberOfAssets = _branch.GetLibraryAssets(a.Id).Count(), NumberOfPatrons = _branch.GetPatrons(a.Id).Count() }).ToList(); var model = new BranchIndexModel { Branches = branches }; return(View(model)); }
public IActionResult Index() { var branches = _branch.GetAll() .Select(b => new BranchDetailModel { Id = b.Id, Name = b.Name, IsOpen = _branch.IsBranchOpen(b.Id), NumberOfAssets = _branch.GetAssets(b.Id).Count(), NumberOfPatrons = _branch.GetPatrons(b.Id).Count() }); var model = new BranchIndexModel { Branches = branches }; return(View(model)); }
public IActionResult Index() { var branches = _branch.GetAll().Select(branch => new BranchDetailModel { Id = branch.Id, BranchName = branch.Name, IsOpen = _branch.IsBranchOpen(branch.Id), NumberOfAssets = _branch.GetAssets(branch.Id).Count(), NumberOfPatrons = _branch.GetPatrons(branch.Id).Count() }); //Create a view Model to return to the Index View var model = new BranchIndexModel() { Branches = branches }; return(View(model)); }
public IActionResult Detail(int id) { var branch = _branch.Get(id); var model = new BranchDetailModel { Id = branch.Id, Name = branch.Name, Address = branch.Address, Telephone = branch.Telephone, Description = branch.Description, OpenedDate = branch.OpenDate.ToString("yyyy-MM-dd"), NumberOfAssets = _branch.GetAssets(id).Count(), NumberOfPatrons = _branch.GetPatrons(id).Count(), TotalAssetValue = _branch.GetAssets(id).Sum(a => a.Cost), ImageUrl = "/images/" + branch.ImageUrl, }; return(View(model)); }