Пример #1
0
        /// <summary>
        /// Get all Loans
        /// </summary>
        /// <returns>List of Loans</returns>
        public HttpResponseMessage Get()
        {
            IEnumerable <LoanModel> result = null;

            try
            {
                result = _repo.GetAll();
            }
            catch (Exception)
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent("Something went wrong, please contact administrator."),
                    ReasonPhrase = "Internal Server Error"
                };
                throw new HttpResponseException(response);
            }

            if (result == null)
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent("No Loans found"),
                    ReasonPhrase = "Loans Not Found"
                };
                throw new HttpResponseException(response);
            }
            return(Request.CreateResponse(HttpStatusCode.OK, _repo.GetAll()));
        }
Пример #2
0
        public void LoanRepository_GetAll_ShouldBeOk()
        {
            var listExpectedLoan = _repository.GetAll();

            listExpectedLoan.Should().NotBeNull();
            listExpectedLoan.Last().Id.Should().Be(1);
        }
Пример #3
0
        public IActionResult Get()
        {
            var items = _loanRepository.GetAll();
            var dto   = _mapper.Map <IEnumerable <LoanDto> >(items);

            return(Ok(dto.ToArray()));
        }
Пример #4
0
        public ComputerModelDTO GetComputer(int id)
        {
            ComputerModelDTO computer = _mapper.Map <ComputerModelDTO>(_computerRepository.Get(id));

            computer.States = _mapper.Map <IEnumerable <StateModelDTO> >(_stateRepository.GetAll()).ToList();

            LoanModelDTO loan = _mapper.Map <IEnumerable <LoanModelDTO> >(_loanRepository.GetAll()).Where(l => l.ComputerId == computer.Id).OrderByDescending(l => l.LoanDate).FirstOrDefault();

            if (loan != null)
            {
                computer.LendBy = _userRepository.GetUsernameById(loan.UserId);

                if (loan.LoanDate != null)
                {
                    computer.LoanDate = loan.LoanDate;
                }

                if (loan.ReturnedDate != null)
                {
                    computer.ReturnedDate = loan.ReturnedDate;
                }
            }

            return(computer);
        }
Пример #5
0
        public async Task <LoanAdminDetailsViewModel> Handle(GetLoanAdminDetailsQuery request, CancellationToken cancellationToken)
        {
            List <Loan> allLoans = new List <Loan>();

            allLoans = await _repository.GetAll();

            List <Loan> loans            = new List <Loan>();
            List <Loan> loanApplications = new List <Loan>();

            if (allLoans != null)
            {
                foreach (Loan loan in allLoans)
                {
                    if ((bool)loan.Granted)
                    {
                        loans.Add(loan);
                    }
                    else
                    {
                        loanApplications.Add(loan);
                    }
                }
            }

            LoanAdminDetailsViewModel model = new LoanAdminDetailsViewModel
            {
                Loans            = loans,
                LoanApplications = loanApplications
            };

            return(model);
        }
Пример #6
0
        public IEnumerable <Loan> GetAll()
        {
            var clients = _clientService.GetAll();
            var loans   = _loanRepository.GetAll();

            BindClientsWithLoans(clients, loans);
            return(loans);
        }
Пример #7
0
        public IActionResult Index()
        {
            //ViewBag.CourseName = db2.GetAll();
            //var applicationDbContext = _context.Courses.Include(t => t.CourseName);
            var applicationDbContext = _context.Branches.ToList();

            return(View(db.GetAll()));
        }
        private Loan GetLoan(IDialog dialog)
        {
            IList <string> arguments = new List <string>();

            arguments.Add("Select loan: \n");

            int i = 0;

            foreach (Loan loan in loanRepository.GetAll())
            {
                i++;
                arguments.Add(i.ToString() + ". " + "Id: " + loan.loanIdProperty + "\n");
            }

            if (i == 0)
            {
                return(null);
            }
            int  result;
            bool parseResult = int.TryParse(dialog.ShowDialogSingle(arguments), out result);

            return(loanRepository.GetAll().ElementAt(result - 1));
        }
        /// <summary>
        /// Get all loans from system
        /// </summary>
        /// <returns></returns>
        public List <LoanDTO> GetAll()
        {
            try
            {
                // call repository method to get all loans
                var loansList = _mapper.Map <List <Loan>, List <LoanDTO> >(_repository.GetAll());

                return(loansList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #10
0
        public void LoanSqlRepository_GetAll_ShouldBeOk()
        {
            //Cenário
            int sizeListExpected        = 1;
            int idFirstLoanListExpected = 1;

            //Executa
            List <Loan> result = _repository.GetAll() as List <Loan>;

            //Saída
            result.Should().NotBeNull();
            result.Count().Should().Be(sizeListExpected);
            result.First().Id.Should().Be(idFirstLoanListExpected);
        }
Пример #11
0
 public IEnumerable <Loan> GetAll()
 {
     return(_repository.GetAll());
 }
Пример #12
0
 public IEnumerable <Loan> All()
 {
     return(LoanRepository.GetAll());
 }
Пример #13
0
 public List <Loan> GetAll()
 {
     return(_loanRepository.GetAll());
 }
Пример #14
0
 public LoansViewModel ShowLoans()
 {
     return(_loanRepository.GetAll());
 }
Пример #15
0
 public async Task <IList <LoanModel> > GetAll(LoanRequestModel request)
 {
     return(_mapper.Map <IList <LoanModel> >((await _loanRepository.GetAll(request))));
 }
Пример #16
0
 public IList <Loan> GetAll()
 {
     return(_repository.GetAll());
 }
Пример #17
0
        // public LoanService() { }

        public IEnumerable <LoanViewModel> ListAll()
        {
            var list = _loanRepository.GetAll();

            return(list.Loans);
        }
Пример #18
0
        public async Task <List <Loan> > GetAllLoans()
        {
            var loans = await _loanRepository.GetAll();

            return(loans.Select(x => _loanMapper.MapToDomain(x)).ToList());
        }
Пример #19
0
 public async Task <List <LoanDTO> > Handle(GetLoansListQuery request, CancellationToken cancellationToken)
 {
     return(_mapper.Map <List <LoanDTO> >(await _repository.GetAll()));
 }
        public IEnumerable <LoanConfig> GetAll()
        {
            var result = _loan.GetAll();

            return(result);
        }