コード例 #1
0
        // GET: Deposits
        public async Task <IActionResult> Index(string?searchCurrency, decimal?searchAmount)
        {
            var deposits = await _depositService.Get();

            ViewBag.CurrencyEnums = typeof(Currency);
            deposits = await _depositService.GetFilteredDeposits(searchCurrency, searchAmount);

            if (searchAmount != null)
            {
                if (deposits.Count() > 1)
                {
                    Alert($"You Have found {deposits.Count()} Deposits", NotificationType.success);
                }
                else if (deposits.Count() == 1)
                {
                    Alert("You Have found 1 Deposit", NotificationType.success);
                }
                else
                {
                    Alert("Sorry, There is no such a kind of Deposit", NotificationType.info);
                }
            }

            var Deposit = _mapper.Map <IEnumerable <Deposit> >(deposits.ToList());

            return(View(Deposit));
        }
コード例 #2
0
 // GET api/deposit/5
 public IHttpActionResult Get(int id)
 {
     try
     {
         return(Ok(_depositService.Get(id)));
     }
     catch (BankClientException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
コード例 #3
0
        public async Task <IEnumerable <Deposit> > GetDepositsList(string orderBy)
        {
            var depositsList = await _depositService.Get();

            if (orderBy != null)
            {
                var isColumnValid = SortingDictionaries.DepositSortings.TryGetValue(orderBy, out var sortFunc);

                if (isColumnValid)
                {
                    depositsList = orderBy.Contains("Desc")
                                                ? depositsList.OrderByDescending(sortFunc)
                                                : depositsList.OrderBy(sortFunc);
                }
            }

            return(depositsList);
        }
コード例 #4
0
        // GET: Accounts/Details/5
        public async Task <IActionResult> Details(int id)
        {
            var account = await _account.GetById(id);

            if (account == null)
            {
                return(NotFound());
            }

            var loans = await _loanService.Get();

            ViewBag.loans = loans;
            var deposits = await _depositService.Get();

            ViewBag.deposits = deposits;

            return(View(account));
        }
コード例 #5
0
        public IHttpActionResult GetCapitalizationPlan(DepositModelForCapitalizationPlan request)
        {
            try
            {
                var deposit = depositService.Get(request.DepositId);
                validationService.ValidateSum(request.Sum, deposit.MinSum, deposit.MaxSum, ModelState);
                validationService.ValidateMonthCount(request.MonthCount, deposit.MinMonthPeriod, deposit.MaxMonthPeriod, ModelState);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var plan = calculationDepositService.CalculateCapitalizationPlan(request.Sum, request.PercentRate, request.MonthCount, request.StartDate).ToList();
                return(Ok(plan));
            }
            catch (BankClientException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
コード例 #6
0
        public async Task <IActionResult> Details(int depositId)
        {
            var deposit = await _depositService.Get(depositId);

            return(View(deposit));
        }