Esempio n. 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));
        }
Esempio n. 2
0
        public IActionResult Update(BranchDetailModel branch, IFormFile ImageUrl)
        {
            string message = "";
            var    data    = _branch.GetById(branch.Id);

            data.Id          = branch.Id;
            data.Name        = branch.Name;
            data.Address     = branch.Address;
            data.Telephone   = branch.Telephone;
            data.Description = branch.Description;
            data.OpenDate    = branch.OpenDate;

            if (ImageUrl != null)
            {
                branch.ImageURL = "/images/branch/" + ImageUrl.FileName;
                data.ImageUrl   = branch.ImageURL;
                var fileName = Path.Combine(he.WebRootPath + "/images/branch", Path.GetFileName(ImageUrl.FileName));
                ImageUrl.CopyTo(new FileStream(fileName, FileMode.Create));
            }
            bool result = _branch.Update(data);

            if (result)
            {
                message += "Update succesfully!";
            }
            else
            {
                message += "Fail to update";
            }
            //return Content(message);
            return(RedirectToAction("ListBranch"));
        }
Esempio n. 3
0
 public IActionResult Post([FromBody] BranchDetailModel value)
 {
     if (value == null)
     {
         return(BadRequest());
     }
     else
     {
         return(Ok());
     }
 }
Esempio n. 4
0
        public IActionResult EditBranch(int id)
        {
            var branch = _branch.GetById(id);
            var model  = new BranchDetailModel
            {
                Id          = branch.Id,
                ImageURL    = branch.ImageUrl,
                Name        = branch.Name,
                Address     = branch.Address,
                Telephone   = branch.Telephone,
                Description = branch.Description,
                OpenDate    = branch.OpenDate
            };

            return(View(model));
        }
Esempio n. 5
0
        public IActionResult Detail(int id)
        {
            var branchDetail = _ILibraryBranches.GetById(id);

            var model = new BranchDetailModel()
            {
                Id                  = id,
                Name                = branchDetail.Name,
                Address             = branchDetail.Address,
                Telephone           = branchDetail.Telephone,
                ImageUrl            = branchDetail.ImageURL,
                Description         = branchDetail.Description,
                OpeningClosingHours = branchDetail.OpenDate
            };

            return(View(model));
        }
Esempio n. 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)
            };
        }
Esempio n. 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 = _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));
        }
        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));
        }
Esempio n. 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));
        }
Esempio n. 12
0
        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,
                OpenDate        = branch.FoundationDate.ToString("yyyy-MM-dd"),
                NumberOfPatrons = _branch.GetPatrons(id).Count(),
                NumberOfAssets  = _branch.GetAssets(id).Count(),
                TotalAssetValue = _branch.GetAssets(id).Sum(a => a.Cost),
                ImageURL        = branch.ImageUrl,
                HoursOpen       = _branch.GetBranchHours(id)
            };

            return(View(model));
        }
Esempio n. 13
0
        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,
                Description     = branch.Description,
                OpenedDate      = branch.OpenDate.ToString("yyyy-MM-dd"),
                NumberOfAssets  = _branch.GetAssets(id).Count(),
                NumberOfPatrons = _branch.GetPatrons(id).Count(),
                TotalAssetValue = _branch.GetAssets(id).Sum(a => a.Cost),
                ImageUrl        = "/images/" + branch.ImageUrl,
            };

            return(View(model));
        }
Esempio n. 14
0
        public IActionResult Detail(int id)
        {
            var branch = this.branch.Get(id);

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

            return(View(model));
        }
        public IActionResult Detail(int id)
        {
            var branchModel = _branchService.GetById(id);
            var model       = new BranchDetailModel
            {
                BranchId       = id,
                Name           = branchModel.Name,
                Address        = branchModel.Address,
                Location       = branchModel.City + ", " + branchModel.Province,
                ImageUrl       = branchModel.ImageUrl,
                Telephone      = branchModel.Telephone,
                OpenDate       = branchModel.OpenDate.ToString("yyyy-MM-dd"),
                HoursOpen      = _branchService.GetBranchHours(id),
                IsOpen         = _branchService.IsBranchOpen(id),
                BranchAssets   = _branchService.GetAssets(id),
                NumberOfAssets = _branchService.GetAssets(id).Count()
            };

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

            var model = new BranchDetailModel
            {
                Id              = branch.BranchId,
                Name            = branch.Name,
                Address         = branch.Address,
                Telephone       = branch.Telephone,
                OpenDate        = branch.OpenDate.Value.ToString("dd-MM-yyyy"),
                NumberOfAssets  = _branchService.GetAssets(branch.BranchId).Count(),
                NumberOfPatrons = _branchService.GetPatrons(branch.BranchId).Count(),
                TotalAssetValue = Math.Round(_branchService.GetAssets(branchId).Sum(a => a.Cost), 2),
                ImageUrl        = branch.ImageUrl,
                HoursOpen       = _branchService.GetBranchHours(branchId)
            };

            return(View(model));
        }
Esempio n. 17
0
        public IActionResult Detail(int id)
        {
            var branch = _branch.Get(id);
            var model  = new BranchDetailModel
            {
                Id              = branch.Id,
                Address         = branch.Address,
                Description     = branch.Description,
                HoursOpen       = _branch.GetBranchHours(id),
                ImageUrl        = branch.ImageUrl,
                IsOpen          = _branch.IsBranchOpen(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)
            };

            return(View(model));
        }
Esempio n. 18
0
        public IActionResult Detail(int Id)
        {
            var p     = _branch.GetById(Id);
            var model = 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(Id).Count(),
                TotalLibraryAssetCount = _branch.GetAllAssets(Id).Count(),
                ImageUrl               = "",
                IsOpen                 = _branch.IsOpen(Id),
                TotalLibraryAssetValue = _branch.GetAllAssets(Id).Sum(a => a.Cost),
                HoursOpen              = _branch.GetHours(Id)
            };

            return(View(model));
        }
Esempio n. 19
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));
        }
Esempio n. 20
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));
        }
Esempio n. 21
0
        public IActionResult Detail(int id)
        {
            //Get the Branches
            var branch = _branch.Get(id);

            //Retrun the DetailModel
            var model = new BranchDetailModel
            {
                Id               = branch.Id,
                BranchName       = branch.Name,
                Address          = branch.Address,
                Telephone        = branch.Telephone,
                BranchOpenedDate = branch.OpenDate.ToString("yyy-MM-dd"),
                NumberOfAssets   = _branch.GetAssets(id).Count(),
                NumberOfPatrons  = _branch.GetPatrons(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 a = _branch.GetById(Id);

            var model = new BranchDetailModel
            {
                Id              = a.Id,
                BranchName      = a.Name,
                Address         = a.Address,
                TelephoneNumber = a.Telephone,
                Description     = a.Description,
                isOpen          = _branch.isBranchOpen(a.Id),
                NumberOfAssets  = _branch.GetLibraryAssets(a.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(a.Id).Count(),
                ImgUrl          = a.ImageUrl,
                OpenDate        = a.OpenDate.ToString("yyyy-MM-dd"),
                TotalAssetValue = _branch.GetLibraryAssets(Id).Sum(c => c.Cost),
                HoursOpen       = _branch.GetBranchHours(a.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,
                Description     = branch.Description,
                ImageUrl        = branch.ImageUrl,
                TelephoneNumber = branch.Telephone,
                OpenDate        = branch.OpenDate.ToString(),
                IsOpen          = _branch.IsBranchOpen(branch.Id),
                OpenHours       = _branch.GetBranchHours(branch.Id),
                NumberOfAssets  = _branch.GetAssets(branch.Id).Count(),
                NumberOfPatrons = _branch.GetPatrons(branch.Id).Count(),
                TotalAssetValue = _branch.GetAssets(branch.Id).Select(a => a.Cost).Sum()
            };

            return(View(model));
        }
Esempio n. 24
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));
        }