示例#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));
        }
示例#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 Detail(int?id)
        {
            if (id == null)
            {
                return(View("NoIdFound"));
            }

            var branch = _branch.GetBranchById((int)id);

            if (branch == null)
            {
                Response.StatusCode = 404;
                return(View("BranchNotFound", id));
            }

            var model = new BranchDetailViewModel()
            {
                Id              = branch.Id,
                Name            = branch.Name,
                Address         = branch.Address,
                Telephone       = branch.Telephone,
                Description     = branch.Description,
                OpenDate        = branch.OpenDate.ToString("yyyy-MM-dd"),
                NumberOfAssets  = _branch.GetAssets((int)id).Count(),
                NumberOfPatrons = _branch.GetPatrons((int)id).Count(),
                TotalAssetValue = _branch.GetAssets((int)id).Sum(x => x.Cost),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours((int)id)
            };

            return(View(model));
        }
示例#4
0
        public async Task <IActionResult> Detail(int?id)
        {
            if (id == null)
            {
                return(View("NoIdFound"));
            }

            var branch = _branch.GetBranchById(id.Value);

            if (branch == null)
            {
                Response.StatusCode = 404;
                return(View("BranchNotFound", id));
            }

            var model = _mapper.Map <BranchDetailViewModel>(branch);

            model.HoursOpen = _branch.GetBranchHours(id.Value);

            var branchAssets = await _branch.GetAssetsAsync(id.Value);

            model.NumberOfAssets  = branchAssets.Count();
            model.TotalAssetValue = branchAssets.Sum(x => x.Cost);
            model.NumberOfPatrons = (await _branch.GetPatronsAsync(id.Value)).Count();

            return(View(model));
        }
        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));
        }
示例#6
0
        public IActionResult Detail(int id)
        {
            var branch = _branch.Get(id);

            var model = new BranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                Telephone       = branch.Telephone,
                OpenDate        = branch.OpenDate.ToString("yyyy-mm-dd"),
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count(),
                TotalAssetValue = _branch.GetAssets(id).Sum(x => x.Cost),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(id)
            };
        }
示例#7
0
        public IActionResult Detail(int id)
        {
            Models.LibraryBranch branch = _branch.GetById(id);//.LibraryBranches.ToList();
            if (branch == null)
            {
                return(RedirectToAction("Index"));
            }
            BranchDetailModel model = new BranchDetailModel(branch)
            {
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count(),
                TotalAssetValue = _branch.GetAssets(branch.Id).Sum(c => c.Cost),
                HoursOpen       = _branch.GetBranchHours(branch.Id),
            };

            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,
                OpenDate        = branch.OpenDate.ToString("yyyy-MM-dd"),
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfMembers = _branch.GetMembers(id).Count(),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(id)
            };

            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));
        }
示例#10
0
        public IActionResult Detail(int id)
        {
            var branch = _branch.GetBy(id);
            var model  = new BranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                Address         = branch.Address,
                PhoneNo         = branch.Telephone,
                OpenDate        = branch.OpenDate.ToString("dd-MM-yyyy"),
                NumberOfAssets  = _branch.GetAssets(id).Count(),
                NumberOfPatrons = _branch.GetAssets(id).Count(),
                TotalAssetValue = _branch.GetAssets(id).Sum(a => a.Cost),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(id)
            };

            return(View(model));
        }
        public IActionResult Detail(int Id)
        {
            var branch = _branch.Get(Id);

            var model = new BranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                MobileNumber    = branch.MobileNumber,
                OpenDate        = branch.OpenDate,
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count(),
                TotalAssetValue = _branch.GetAssets(Id).Sum(a => a.Cost),
                ImageURl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(Id)
            };

            return(View(model));
        }
示例#12
0
        public IActionResult Detail(int id)
        {
            var branch = _branch.Get(id);

            var model = new LibraryBranchDetailModel()
            {
                Id              = branch.Id,
                Name            = branch.Name,
                Address         = branch.Address,
                Telephone       = branch.Telephone,
                OpenDate        = branch.OpenDate.ToString("dd-MM-yyyy"),
                NumberOfAssets  = _branch.GetAllAssets(id).Count(),
                NumberOfPatrons = _branch.GetAllPatrons(id).Count(),
                TotlaAssetValue = _branch.GetAllAssets(id).Sum(asset => asset.Cost),
                ImageUrl        = branch.ImageUrl,
                BranchHours     = _branch.GetBranchHours(id)
            };

            return(View(model));
        }
示例#13
0
        public IActionResult Detail(int branchId)
        {
            var branch = _branch.Get(branchId);

            var model = new BranchDetailModel
            {
                Id              = branch.Id,
                Name            = branch.Name,
                Address         = branch.Address,
                Telephone       = branch.Phone,
                OpenDate        = branch.OpenDate,
                IsOpen          = _branch.IsBranchOpen(branch.Id),
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count(),
                TotalAssetValue = _branch.GetAssets(branch.Id).Sum(a => a.Cost),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(branch.Id)
            };

            return(View(model));
        }
示例#14
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));
        }
示例#15
0
        public IActionResult Detail(int id)
        {
            var branch = _branch.Get(id);

            var model = new BranchDetailModel
            {
                Id              = branch.Id,
                Address         = branch.Address,
                Name            = branch.Name,
                OpenDate        = branch.OpenDate.ToString("yyyy:MM:dd"),
                Telephone       = branch.Telephone,
                IsOpen          = _branch.IsBranchOpen(branch.Id), // branch.Id == id
                Description     = branch.Description,
                NumberOfPatrons = _branch.GetPatrons(id).Count(),
                NumberOfAssets  = _branch.GetAssets(id).Count(),
                TotalAssetValue = _branch.GetAssets(id).Sum(asset => asset.Cost),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(id)
            };

            return(View(model));
        }
示例#16
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));
        }