Пример #1
0
        public async Task <IActionResult> AcceptTermsAndConditionsViewAsync(Guid loanUID)
        {
            if (loanUID == null || loanUID == Guid.Empty)
            {
                return(Json("Page not found"));
            }

            LoanResponse _Response = await __LoanManager.GetByUIDAsync(loanUID);

            if (_Response == null)
            {
                return(Json("Page not found"));
            }

            LoanViewModel _LoanViewModel = __Mapper.Map <LoanViewModel>(_Response);
            IList <Guid>  _EquipmentUIDs = (await __LoanEquipmentManager.GetAsync(_Response.UID)).Select(x => x.EquipmentUID).ToList();

            if (_EquipmentUIDs != null && _EquipmentUIDs.Count > 0)
            {
                _LoanViewModel.EquipmentList = __Mapper.Map <IList <Equipment.Models.EquipmentViewModel> >((await __EquipmentManager.GetAsync(_EquipmentUIDs)).Equipments);
            }

            if (_Response.AcceptedTermsAndConditions)
            {
                AlreadyAcceptedTermsAndConditionsViewModel _AlreadyAcceptedModel = new AlreadyAcceptedTermsAndConditionsViewModel
                {
                    UID      = loanUID,
                    Accepted = _Response.AcceptedTermsAndConditions,
                    Loan     = _LoanViewModel
                };

                return(View("AlreadyAcceptedTermsAndConditions", _AlreadyAcceptedModel));
            }

            AcceptTermsAndConditionsViewModel _Model = new AcceptTermsAndConditionsViewModel
            {
                UID      = loanUID,
                Accepted = _Response.AcceptedTermsAndConditions,
                Loan     = _LoanViewModel,
                TermsAndConditionsStatement = (await __ConfigurationManager.GetByNormalizedNameAsync(__Configuration.GetValue <string>("Configuration:Loan:TERMS_AND_CONDITIONS")))?.Value ?? string.Empty
            };

            return(View("AcceptTermsAndConditions", _Model));
        }
Пример #2
0
        public async Task <IActionResult> AcceptTermsAndConditionsAsync(AcceptTermsAndConditionsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewData["ErrorMessage"] = "Invalid form submission";
                return(View("AcceptTermsAndConditions", model));
            }

            BaseResponse _Response = await __LoanManager.AcceptTermsAndConditions(model.UID);

            if (!_Response.Success)
            {
                ModelState.AddModelError("Error", _Response.Message);
                return(await AcceptTermsAndConditionsViewAsync(model.UID));
            }

            LoanResponse _Loan = await __LoanManager.GetByUIDAsync(model.UID);

            await __EmailScheduleManager.CreateLoanConfirmedScheduleAsync(_Loan, $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}", true);

            return(View("AcceptedTermsAndConditions"));
        }