Beispiel #1
0
        public DecisionModel TakeDecision(LoanApplicationModel loanApplicationModel)
        {
            var result = loanApplicationModel.MonthlyIncome > 31000;

            return(new DecisionModel()
            {
                Decision = result,
                Description = result ? "Your income is high enough" : "Your income is to low."
            });
        }
Beispiel #2
0
        public int UpdateLoanApplication(LoanApplicationModel loanApplicationModel)
        {
            if (loanApplicationModel == null)
            {
                throw new ArgumentNullException();
            }
            var decisionTaker = DecisionFactory.CreateDecisionTaker(loanApplicationModel.DecisionType);

            loanApplicationModel.Decision = decisionTaker.TakeDecision(loanApplicationModel);
            return(_loanApplicationContextFacade.UpdateLoanApplication(loanApplicationModel));
        }
Beispiel #3
0
        public async Task <LoanApplicationBll> EditAsync(LoanApplicationBll loanApplication)
        {
            LoanApplicationModel model = this._mapper.Map <LoanApplicationModel>(loanApplication);

            LoanApplicationModel updatedModel = await this._repository.UpdateAsync(model);

            await this._unitOfWork.CommitAsync();

            LoanApplicationBll returnModel = this._mapper.Map <LoanApplicationBll>(updatedModel);

            return(returnModel);
        }
Beispiel #4
0
        public async Task <LoanApplicationBll> RemoveAsync(LoanApplicationBll loanApplication)
        {
            LoanApplicationModel model = this._mapper.Map <LoanApplicationModel>(loanApplication);

            LoanApplicationModel deletedModel = this._repository.SoftDelete(model);

            await this._unitOfWork.CommitAsync();

            LoanApplicationBll returnModel = this._mapper.Map <LoanApplicationBll>(deletedModel);

            return(returnModel);
        }
        public static void UpdateEntity(this LoanApplicationModel current, LoanApplicationModel other, LoanApplicationContext context)
        {
            context.Attach(current);
            foreach (var property in typeof(LoanApplicationModel).GetProperties())
            {
                if (property.GetValue(current).Equals(property.GetValue(other)))
                {
                    continue;
                }

                property.SetValue(current, property.GetValue(other));
                context.Entry(current).Property(property.Name).IsModified = true;
            }
        }
        public async Task <LoanApplicationModel> RegisterApplicationAsync(LoanApplicationModel loanApplication, Guid clientId)
        {
            if (!await _clientService.ClientExists(clientId))
            {
                return(null);
            }

            var applicationToSave = _mapper.Map <LoanApplication>(loanApplication);

            applicationToSave.Id       = Guid.NewGuid();
            applicationToSave.Status   = LoanApplicationStatus.Sent;
            applicationToSave.ClientId = clientId;
            await _repository.AddAsync(applicationToSave);

            return(_mapper.Map <LoanApplicationModel>(applicationToSave));
        }
Beispiel #7
0
        public IActionResult Add([FromBody] LoanApplicationModel model)
        {
            if (model == null)
            {
                BadRequest();
            }
            // TODO: This should make sure all values are set (no null values)
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }

            var id = _loanApplicationLogic.CreateLoanApplication(model);

            return(Ok(id));
        }
Beispiel #8
0
        public int UpdateLoanApplication(LoanApplicationModel loanApplicationModel)
        {
            var modelFromDb = _loanApplicationContext.LoanApplications
                              .Include(model => model.Decision)
                              .FirstOrDefault(model => model.Id == loanApplicationModel.Id);

            if (modelFromDb == null)
            {
                return(-1);
            }

            _loanApplicationContext.LoanApplications.Update(modelFromDb);
            modelFromDb.UpdateChangedProperties(loanApplicationModel);
            modelFromDb.Decision.UpdateChangedProperties(loanApplicationModel.Decision);
            _loanApplicationContext.SaveChanges();
            return(modelFromDb.Id);
        }
        public async Task <int> UpdateApplicationAsync(LoanApplicationModel loanApplication)
        {
            LoanApplicationStatus appStatus = (LoanApplicationStatus)loanApplication.Status;

            if (appStatus == LoanApplicationStatus.Approved || appStatus == LoanApplicationStatus.Denied)
            {
                return(-1);
            }

            var applicationToUpdate = _mapper.Map <LoanApplication>(loanApplication);
            var updatableProps      = new[] { nameof(LoanApplication.Currency),
                                              nameof(LoanApplication.LoanAmount),
                                              nameof(LoanApplication.Period),
                                              nameof(LoanApplication.Type), };
            bool updated = await _repository.UpdateAsync(applicationToUpdate, updatableProps);

            return(updated ? 1 : 0);
        }
Beispiel #10
0
        public ActionResult NewLoanApplication(string borrower)
        {
            LoanApplicationModel loan = new LoanApplicationModel();

            loan.AccountNo        = "LA-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString();
            loan.TransactionDate  = DateTime.Now;
            loan.orgs             = customerComp.getOrganization();
            loan.districts        = customerComp.getDistrict();
            loan.applicationTypes = customerComp.getApplicationType();
            loan.products         = service.GetLoanProducts();
            loan.DesiredMLV       = "0.00";

            //  loan.sets = service.GetLoanSet();
            //  loan.terms = service.GetLoanTerms();
            loan.borrowerProfile = service.GetBorrowerProfile(borrower);
            loan.reqDocs         = service.getBorrowerRequiredDocuments(borrower);
            return(View("LoanApplication", loan));
        }
        public static LoanApplicationModel CreateBasicModel()
        {
            var model = new LoanApplicationModel
            {
                Address        = "",
                DecisionType   = DecisionType.Standard,
                FirstName      = "",
                Id             = 0,
                Lastname       = "",
                LoanAmount     = "",
                LoanDuration   = "",
                MonthlyIncome  = 123,
                PersonalNumber = "",
                Street         = "",
                Zip            = "",
            };

            return(model);
        }
        public ActionResult CreateLoanApplication(LoanApplicationModel loanapplicationmodel)
        {
            List<GroupLookupDto> lstGroupDto = _groupService.Lookup();
            SelectList lstgroup = new SelectList(lstGroupDto, "GroupID", "GroupCode");
            ViewBag.GroupNames = lstgroup;

            List<LoanPurposeLookupDto> lstLoanpurposeDto = _loanpurposeService.Lookup();
            SelectList lstloanpurpose = new SelectList(lstLoanpurposeDto, "LoanPurposeID", "Purpose");
            ViewBag.LoanPurposeName = lstloanpurpose;

            var resultDto = new ResultDto();
            var loanapplicationDto = Mapper.Map<LoanApplicationModel, LoanApplicationDto>(loanapplicationmodel);
            loanapplicationDto.UserID = UserInfo.UserID;
            if (loanapplicationDto.LoanMasterId == 0)
                resultDto = _loanapplicationService.Insert(loanapplicationDto);
            else
                resultDto = _loanapplicationService.Update(loanapplicationDto);

            ViewBag.Result = resultDto;

            return View(loanapplicationmodel);
        }
 public static LoanApplicationModel WithId(this LoanApplicationModel model, int id)
 {
     model.Id = id;
     return(model);
 }
Beispiel #14
0
 public int CreateLoanApplication(LoanApplicationModel loanApplicationModel)
 {
     _loanApplicationContext.LoanApplications.Add(loanApplicationModel);
     _loanApplicationContext.SaveChanges();
     return(loanApplicationModel.Id);
 }
Beispiel #15
0
        public async Task <IActionResult> Put([FromBody] LoanApplicationModel loanApplication)
        {
            int status = await _service.UpdateApplicationAsync(loanApplication);

            return(status != 1 ? (IActionResult)BadRequest() : NoContent());
        }
Beispiel #16
0
        public async Task <IActionResult> Add([FromBody] LoanApplicationModel loanApplication, Guid clientId)
        {
            var result = await _service.RegisterApplicationAsync(loanApplication, clientId);

            return(result != null ? (IActionResult)Ok(result) : BadRequest());
        }