/**
         * The PopulateBranchDropDownList method gets a list of all branches sorted by name, creates a SelectList
         * collection for a drop-down list, and passes the collection to the view in a ViewBag property. The method accepts
         * the optional selectedBranch parameter that allows the calling code to specify the item that will be selected
         * when the drop-down list is rendered. The view will pass the name BranchID to the DropDownList helper, and the
         * helper then knows to look in the ViewBag object for a SelectList named BranchID.
         **/

        private void PopulateBranchesDropDownList(object selectedBranch = null)
        {
            var branchesQuery = from d in _branchInformationService.GetAll()
                                orderby d.BranchName
                                select d;

            ViewBag.BranchID = new SelectList(branchesQuery, "Id", "BranchName", selectedBranch);
        }
        public IActionResult Index()
        {
            var branchesInformation = _branchInformationService.GetAll()
                                      .Select(branchInformation => new BranchInformationViewModel
            {
                Id         = branchInformation.Id,
                BranchName = branchInformation.BranchName,
                BranchCode = branchInformation.BranchCode,
                Province   = branchInformation.Province,
                City       = branchInformation.City
            });

            var model = new BranchInformationIndexModel
            {
                BranchInformationList = branchesInformation
            };

            return(View(model));
        }