Exemplo n.º 1
0
        public IHttpActionResult GetPaymentPlan(CalculationCreditModelForPaymentPlan request)
        {
            try
            {
                var credit = creditService.Get(request.CreditId);
                validationService.ValidateSum(request.Sum, credit.MinSum, credit.MaxSum, ModelState);
                validationService.ValidateMonthCount(request.MonthCount, credit.MinMonthPeriod, credit.MaxMonthPeriod, ModelState);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var payments = calculationCreditService
                               .CalculatePaymentPlan(request.Sum, credit.PercentRate, request.MonthCount, request.StartDate);
                var viewPayments =
                    Mapper.Map <IEnumerable <DomainCreditPaymentPlanItem>, List <CreditPaymentPlanViewModel> >(payments);
                return(Ok(viewPayments));
            }
            catch (BankClientException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public async Task <IActionResult> PaymentsByService(int?pageNumber, string query = null)
        {
            int pageSize = 25;
            var profiles = _creditService.Get().Include(x => x.appointment_).Include(y => y.appointment_.appointment_sub_typeNavigation).Where(x => x.appointment_ != null && x.appointment_.appointment_sub_typeNavigation != null);

            return(View(await PaginatedList <mp_credit> .CreateAsync(profiles.OrderByDescending(e => e.created_at).AsNoTracking(), pageNumber ?? 1, pageSize)));
        }
Exemplo n.º 3
0
//        [Route("GetById")]
        // GET api/credit/5
        public IHttpActionResult Get(int id)
        {
            try
            {
                return(Ok(creditService.Get(id)));
            }
            catch (BankClientException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Index()
        {
            var model = await _creditService.Get();

            return(View(model));
        }