예제 #1
0
        public async Task <IActionResult> Detail(int id)
        {
            var serviceResult = await _branchService.Get(id);

            var patronCount = await _branchService.GetPatronCount(id);

            var assetsCount = await _branchService.GetAssetCount(id);

            var assetsValue = await _branchService.GetAssetsValue(id);

            var branchHoursResult = await _branchService.GetBranchHours(id);

            var branchHours = branchHoursResult ?? new List <string>();

            var model = new BranchDetailModel {
                BranchName       = serviceResult.Name,
                Description      = serviceResult.Description,
                Address          = serviceResult.Address,
                Telephone        = serviceResult.Telephone,
                BranchOpenedDate = serviceResult.OpenDate.ToString("yyyy-MM-dd"),
                NumberOfPatrons  = patronCount,
                NumberOfAssets   = assetsCount,
                TotalAssetValue  = assetsValue,
                ImageUrl         = serviceResult.ImageUrl,
                HoursOpen        = branchHours
            };

            return(View(model));
        }
        public IActionResult Detail(int id)
        {
            var branch = _branchService.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  = _branchService.GetPatronCount(id),
                NumberOfAssets   = _branchService.GetAssetCount(id),
                ImageUrl         = branch.ImageUrl,
                HoursOpen        = _branchService.GetBranchHours(id)
            };

            return(View(model));
        }