Ejemplo n.º 1
0
        public IActionResult Index()
        {
            if (HttpContext.Session.GetString("username") == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            else if (HttpContext.Session.GetInt32("role_id") == 3)
            {
                return(RedirectToAction("Login", "Home"));
            }
            else
            {
                var branchModels = _branchService.GetAll()
                                   .Select(br => new BranchDetailModel
                {
                    Id              = br.Id,
                    BranchName      = br.Name,
                    NumberOfAssets  = _branchService.GetAssetCount(br.Id),
                    NumberOfPatrons = _branchService.GetPatronCount(br.Id),
                    IsOpen          = _branchService.IsBranchOpen(br.Id)
                }).ToList();

                var model = new BranchIndexModel
                {
                    Branches = branchModels
                };

                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index([FromQuery] int page = 1, [FromQuery] int perPage = 10)
        {
            var paginatedBranches = await _branchService.GetPaginated(page, perPage);

            if (paginatedBranches.Results.Any())
            {
                foreach (var branch in paginatedBranches.Results)
                {
                    var branchId = branch.Id;
                    branch.IsOpen = await _branchService.IsBranchOpen(branchId);

                    branch.NumberOfAssets = await _branchService.GetAssetCount(branchId);

                    branch.NumberOfPatrons = await _branchService.GetPatronCount(branchId);
                }

                var model = new BranchIndexModel {
                    PageOfBranches = paginatedBranches
                };

                return(View(model));
            }

            var emptyModel = new BranchIndexModel {
                PageOfBranches = new PaginationResult <LibraryBranchDto> {
                    Results    = new List <LibraryBranchDto>(),
                    PageNumber = page,
                    PerPage    = perPage
                }
            };

            return(View(emptyModel));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        public IActionResult Index()
        {
            var branches = _branch.GetAll()
                           .Select(b => new BranchDetailModel(b)
            {
                NumberOfAssets  = _branch.GetAssets(b.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(b.Id).Count(),
                //////////////IsOpen = _branch.IsBranchOpen(b.Id),
            });
            BranchIndexModel model = new BranchIndexModel()
            {
                Branches = branches
            };

            return(View(model));
        }
Ejemplo n.º 6
0
        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));
        }
        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));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
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);
        }
        public IActionResult Index()
        {
            var model = _IBrancheService.GetAll()
                        .Select(b => new BranchListingModel {
                Id          = b.Id,
                Name        = b.Name,
                Address     = b.Address,
                Description = b.Description,
                ImageUrl    = b.ImageUrl,
                OpenDate    = b.OpenDate,
                Telephone   = b.Telephone
            });

            var brancheModel = new BranchIndexModel {
                ListingModels = model
            };

            return(View(brancheModel));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
0
        public IActionResult Index()
        {
            var branchModels = _ILibraryBranches.GetAll();

            var listingResults = branchModels.Select(result => new BranchesIndexListingModel()
            {
                Id                  = result.Id,
                Name                = result.Name,
                Address             = result.Address,
                ImageUrl            = result.ImageURL,
                OpeningClosingHours = result.OpenDate
            });

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

            return(View(model));
        }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
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));
        }
Ejemplo n.º 16
0
        public IActionResult Index()
        {
            var allBranchesModel = _branchService.GetAll();

            var listingResult = allBranchesModel
                                .Select(result => new BranchIndexListingModel
            {
                BranchId  = result.Id,
                Name      = result.Name,
                Address   = result.Address,
                Location  = result.City + ", " + result.Province,
                Telephone = result.Telephone,
                ImageUrl  = result.ImageUrl
            });

            var model = new BranchIndexModel
            {
                Branches = listingResult
            };

            return(View(model));
        }
Ejemplo n.º 17
0
        public IActionResult Index()
        {
            var Tempmodel = _branch.GetAll().Select(p => new BranchDetailModel
            {
                Id                     = p.Id,
                Name                   = p.Name,
                Address                = p.Address,
                Telephone              = p.Telephone,
                Description            = p.Description,
                OpenDate               = p.OpenDate.ToString("yyyyy'-'MM"),
                NumberOfUser           = _branch.GetAllUsers(p.Id).Count(),
                TotalLibraryAssetCount = _branch.GetAllAssets(p.Id).Count(),
                ImageUrl               = "",
                IsOpen                 = _branch.IsOpen(p.Id),
                HoursOpen              = _branch.GetHours(p.Id)
            });
            var model = new BranchIndexModel
            {
                Branches = Tempmodel
            };

            return(View(model));
        }
Ejemplo n.º 18
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));
        }
        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));
        }
Ejemplo n.º 20
0
        public IActionResult Index()
        {
            var totalAssets = _branch.TotalAssets();
            var branch      = _branch.GetAll();
            var List        = branch
                              .Select(result => new BranchDetailModel
            {
                Id          = result.Id,
                ImageURL    = result.ImageUrl,
                Name        = result.Name,
                Address     = result.Address,
                Telephone   = result.Telephone,
                Description = result.Description,
                OpenDate    = result.OpenDate
            });
            var model_branch = new BranchIndexModel()
            {
                Branches    = List,
                TotalAssets = totalAssets,
                TotalPatron = _branch.TotalPatrons()
            };

            return(View(model_branch));
        }
Ejemplo n.º 21
0
        public IActionResult ListBranch()
        {
            var branch = _branch.GetAll();
            var List   = branch
                         .Select(result => new BranchDetailModel
            {
                Id              = result.Id,
                ImageURL        = result.ImageUrl,
                Name            = result.Name,
                Address         = result.Address,
                Telephone       = result.Telephone,
                Description     = result.Description,
                OpenDate        = result.OpenDate,
                NumberOfAssets  = _branch.GetAssetCount(result.Id),
                NumberOfPatrons = _branch.GetPatronCount(result.Id),
                IsOpen          = _branch.IsBranchOpen(result.Id)
            });
            var model_branch = new BranchIndexModel()
            {
                Branches = List
            };

            return(View(model_branch));
        }
Ejemplo n.º 22
0
        public IActionResult Index(string sortOrder, string searchString)
        {
            var branchModels = from c in _branch.GetAll().ToList() select c;

            ViewData["CurrentFilter"]     = searchString;
            ViewData["NameSortParm"]      = sortOrder == "name" ? "name_desc" : "name";
            ViewData["AddressSortParm"]   = sortOrder == "address" ? "address_desc" : "address";
            ViewData["TelephoneSortParm"] = sortOrder == "telephone" ? "telephone_desc" : "telephone";;

            if (!String.IsNullOrEmpty(searchString))
            {
                branchModels = branchModels.Where(c => c.Name.ToUpper().Contains(searchString.ToUpper()) ||
                                                  c.Address.ToUpper().Contains(searchString.ToUpper()) ||
                                                  c.Telephone.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "name":
                branchModels = branchModels.OrderBy(s => s.Name.ToUpper());
                break;

            case "name_desc":
                branchModels = branchModels.OrderByDescending(s => s.Name.ToUpper());
                break;

            case "address":
                branchModels = branchModels.OrderBy(s => s.Address.ToUpper());
                break;

            case "address_desc":
                branchModels = branchModels.OrderByDescending(s => s.Address.ToUpper());
                break;

            case "telephone":
                branchModels = branchModels.OrderBy(s => s.Telephone);
                break;

            case "telephone_desc":
                branchModels = branchModels.OrderByDescending(s => s.Telephone);
                break;

            default:
                branchModels = branchModels.OrderBy(s => s.Id);
                break;
            }

            var branches = branchModels
                           .Select(branch => new BranchDetailModel

            {
                Id        = branch.Id,
                Name      = branch.Name,
                Address   = branch.Address,
                Telephone = branch.Telephone
            });

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

            return(View(model));
        }