Esempio n. 1
0
        public IActionResult Index()
        {
            var branches = _branch.GetAll().Select(branch => new BranchDetailModel
            {
                Id              = branch.Id,
                Address         = branch.Address,
                Description     = branch.Description,
                HoursOpen       = _branch.GetBranchHours(branch.Id),
                ImageUrl        = branch.ImageUrl,
                IsOpen          = _branch.IsBranchOpen(branch.Id),
                Name            = branch.Name,
                NumberOfAssets  = branch.LibraryAssets.Count(),
                NumberOfPatrons = branch.Patrons.Count(),
                OpenDate        = branch.OpenDate.ToString("yyyy-MM-dd"),
                Telephone       = branch.Telephone,
                TotalAssetValue = branch.LibraryAssets.Sum(asset => asset.Cost)
            });

            var model = new BranchIndexModel
            {
                Branches = branches
            };

            return(View(model));
        }
Esempio n. 2
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 Index()
        {
            var branches = _branch.GetAll().Select(branch => new BranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                IsOpen          = _branch.IsBranchOpen(branch.Id),
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count()
            });
            var model = new BranchIndexModel()
            {
                Branches = branches
            };

            return(View(model));
        }
Esempio n. 4
0
        public IActionResult Index()
        {
            IEnumerable <BranchDetailModel> branches = _branches.GetAll().Select(lb => new BranchDetailModel
            {
                Id              = lb.Id,
                BranchName      = lb.Name,
                IsOpen          = _branches.IsBranchOpen(lb.Id) ? "Open" : "Closed",
                NumberOfAssets  = _branches.GetAssetCount(lb.Id),
                NumberOfPatrons = _branches.GetPatronCount(lb.Id)
            });

            BranchIndexModel model = new BranchIndexModel()
            {
                Branches = branches
            };

            return(View(model));
        }
Esempio n. 5
0
        public IEnumerable <BranchDetailModel> GetLibraryBranches()
        {
            var branches = _branch.GetAll().Select(b => new BranchDetailModel
            {
                Id              = b.Id,
                BranchName      = b.Name,
                IsOpen          = _branch.IsBranchOpen(b.Id),
                NumberOfAssets  = _branch.GetAssets(b.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(b.Id).Count(),
            });;

            return(branches);
        }
        public IActionResult Index()
        {
            var branchModels = _branch.GetAll().Select(b => new BranchDetailModel
            {
                Id              = b.Id,
                Name            = b.Name,
                Address         = b.Address,
                Description     = b.Description,
                ImageUrl        = b.ImageUrl,
                TelephoneNumber = b.Telephone,
                OpenDate        = b.OpenDate.ToString(),
                IsOpen          = _branch.IsBranchOpen(b.Id),
                OpenHours       = _branch.GetBranchHours(b.Id),
                NumberOfAssets  = _branch.GetAssets(b.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(b.Id).Count(),
                TotalAssetValue = _branch.GetAssets(b.Id).Select(a => a.Cost).Sum()
            }).ToList();

            var model = new BranchIndexModel {
                Branches = branchModels
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var branchModels = _branchSvc.GetAll().Select(br => new BranchDetailModel
            {
                Id              = br.Id,
                BranchName      = br.Name,
                NumberOfAssets  = _branchSvc.GetAssetCount(br.Id),
                NumberOfPatrons = _branchSvc.GetPatronCount(br.Id),
                IsOpen          = _branchSvc.IsBranchOpen(br.Id)
            }).ToList();

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

            return(View(model));
        }
Esempio n. 8
0
        public IActionResult Index()
        {
            var branches = _branch.GetAll().Select(b => new BranchDetailModel
            {
                Id     = b.Id,
                Name   = b.Name,
                IsOpen = _branch.IsBranchOpen(b.Id),
                //if we have alot asset and patron we should seperate query for more efficent
                NumberOfAssets  = _branch.GetAssets(b.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(b.Id).Count()
            });

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

            return(View(model));
        }
Esempio n. 9
0
        public IEnumerable <BranchDetailModel> Get()
        {
            var branches = _branch.GetAll().Select(branch => new BranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                IsOpen          = _branch.IsBranchOpen(branch.Id),
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count(),
                PhoneNo         = branch.Telephone
            });

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

            return(model.Branches);
        }
Esempio n. 10
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));
        }
Esempio n. 11
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));
        }
Esempio n. 12
0
        public IActionResult Index()
        {
            var allBranches = _branch
                              .GetAllBranches()
                              .Select(branch => new LibraryBranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                isOpen          = _branch.IsBranchOpen(branch.Id),
                NumberOfAssets  = _branch.GetAllAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetAllPatrons(branch.Id).Count(),
                Address         = branch.Address,
                Telephone       = branch.Telephone
            });

            var model = new LibraryBranchIndexModel()
            {
                Branches = allBranches
            };

            return(View(model));
        }
Esempio n. 13
0
        public IActionResult Index()
        {
            var branches = _branch.GetAll().Select(branch => new BranchDeatailModel
            {
                Id          = branch.ID,
                Address     = branch.Address,
                Description = branch.Description,
                ImageUrl    = branch.ImageUrl,
                Name        = branch.Name,
                NOOfAssets  = _branch.GetAssets(branch.ID).Count(),
                NOOfPatrons = _branch.Getpatrons(branch.ID).Count(),
                IsOpen      = _branch.IsBranchOpen(branch.ID),
                Telephone   = branch.Telephone
            });

            var model = new BranchIndexModel
            {
                Branches = branches
            };

            return(View(model));
        }
Esempio n. 14
0
        public IActionResult Index()
        {
            var branches = _branch.GetAll().Select(b => new BranchDetailModel
            {
                Id              = b.Id,
                Name            = b.Name,
                NumberOfAssets  = _branch.GetAssetCount(b.Id),
                NumberOfPatrons = _branch.GetPatronCount(b.Id),
                IsOpen          = _branch.IsBranchOpen(b.Id),
                Address         = b.Address,
                OpenDate        = b.OpenDate.ToString(),
                Telephone       = b.Telephone,
                Description     = b.Description,
                ImageUrl        = b.ImageUrl
            }).ToList();

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

            return(View(model));
        }