Esempio n. 1
0
        public IActionResult Index()
        {
            var branchModels = branch.GetAll()
                               .Select(br => new BranchDetailModel
            {
                Id               = br.Id,
                BranchName       = br.Name,
                NumberOfAssets   = branch.GetAssetCount(br.Id),
                NumberOfPatrons  = branch.GetPatronCount(br.Id),
                IsOpen           = branch.IsBranchOpen(br.Id),
                Description      = br.Description,
                Address          = br.Address,
                Telephone        = br.Telephone,
                BranchOpenedDate = br.OpenDate.ToString("yyyy-MM-dd"),
                TotalAssetValue  = branch.GetAssetsValue(br.Id),
                ImageUrl         = br.ImageUrl,
                HoursOpen        = branch.GetBranchHours(br.Id),
            }).ToList();

            var model = new BranchIndexModel
            {
                Branches = branchModels
            };

            return(View(model));
        }
        public IActionResult Detail(int id)
        {
            var branch = _branch.Get(id);
            var model  = new BranchDetailModel
            {
                BranchName       = branch.Name,
                Description      = branch.Description,
                Address          = branch.Address,
                Telephone        = branch.Telephone,
                BranchOpenedDate = branch.OpenDate.ToString("yyyy-MM-dd"),
                NumberOfPatrons  = _branch.GetPatronCount(id),
                NumberOfAssets   = _branch.GetAssetCount(id),
                TotalAssetValue  = _branch.GetAssetsValue(id),
                ImageUrl         = branch.ImageUrl,
                HoursOpen        = _branch.GetBranchHours(id)
            };

            return(View(model));
        }
Esempio n. 3
0
        public IActionResult Detail(int branchId)
        {
            LibraryBranch branch = _branches.GetLibraryBranch(branchId);

            BranchDetailModel model = new BranchDetailModel()
            {
                Id               = branch.Id,
                BranchName       = branch.Name,
                Address          = branch.Address,
                Description      = branch.Description,
                Telephone        = branch.Telephone,
                BranchOpenedDate = branch.OpenDate.ToString("yyyy-MM-dd"),
                ImageUrl         = branch.ImageUrl,
                IsOpen           = _branches.IsBranchOpen(branch.Id) ? "Open" : "Closed",
                HoursOpen        = _branches.GetBranchHours(branch.Id),
                NumberOfAssets   = _branches.GetAssetCount(branch.Id),
                NumberOfPatrons  = _branches.GetPatronCount(branch.Id),
                TotalAssetValue  = _branches.GetAssetsValue(branch.Id)
            };

            return(View(model));
        }
Esempio n. 4
0
        public async Task <IActionResult> Detail(int id)
        {
            var spec         = new LibraryBranchWithPatronAndAssetsSpecification(id);
            var branchResult = await _branch.ListAsync(spec);

            var branch = branchResult
                         .FirstOrDefault(brch => brch.Id == id);

            var branchModel = new BranchDetailModel
            {
                BranchName       = branch.Name,
                Description      = branch.Description,
                Address          = branch.Address,
                Telephone        = branch.Telephone,
                BranchOpenedDate = branch.OpenDate.ToString("yyyy-MM-dd"),
                NumberOfPatrons  = _branch.GetPatronCount(id),
                NumberOfAssets   = _branch.GetAssetCount(id),
                TotalAssetValue  = _branch.GetAssetsValue(id),
                ImageUrl         = branch.ImageUrl,
                HoursOpen        = _branch.GetBranchHours(id)
            };

            return(View(branchModel));
        }