public void TestGetAllBranchesReturnsBranchListSuccess()
        {
            this.MockGetAllBranchesResponseTables(true);

            var result = branchRepositoryMock.Get(5).Result;

            Assert.IsTrue(result.Result.Count > 0);
            Assert.IsTrue(result.Result[0].MGBranch != null);
            //Assert.Equals(fakeLsitAgencyResponse, result.Result);
        }
Beispiel #2
0
        private async Task <IActionResult> GetAgency(int?id)
        {
            try
            {
                BaseResult <List <Models.Response.Branch> > result = await _iBranchRepository.Get(id);

                if (result.Result == null || result.Result.Count() == 0)
                {
                    if (result.IsError && result.ExceptionMessage != null)
                    {
                        return(new StatusCodeResult(500));
                    }
                    else if (result.Result == null || result.Result.Count() == 0)
                    {
                        return(NoContent()); //204
                    }
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                Dictionary <string, string> inputParameter = new Dictionary <string, string>();
                inputParameter.Add("Id", id.ToString());
                LogHelper.LogError(_iLogger, Constants.AppName, "Get", "Error Occurred. ", "BranchController", ex, Constants.InternalErrorStatusCode, inputParameter);
                return(new StatusCodeResult(500));
            }
        }
Beispiel #3
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));
        }
        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("dd/MM/yyyy"),
                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),
                IsOpen          = _branch.IsBranchOpen(branch.Id)
            };

            return(View(model));
        }
Beispiel #5
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));
        }