public void GetLoanApplicationWithBalance_LoanAmountUnder1000_NullValuesReturned()
        {
            var name            = "sumon";
            var loanApplication = new tblLoanApplication
            {
                Name   = name,
                Amount = 140,
                Id     = 1
            };
            var balance = new tblBalance
            {
                Name    = "sumon",
                Balance = 3500,
                Id      = 3
            };

            _loanApplicationUow.Setup(l => l.Repository <tblLoanApplication>().Get(It.IsAny <Func <tblLoanApplication, bool> >()))
            .Returns(loanApplication);

            _loanApplicationUow.Setup(l => l.Repository <tblBalance>().Get(It.IsAny <Func <tblBalance, bool> >()))
            .Returns(balance);
            var result = _loanApplicationService.GetLoanApplicationWithBalance(name);

            (result.BalanceAmount).Should().Be(null);
            (result.LoanAmount).Should().Be(null);
        }
Esempio n. 2
0
        public override void FillSelectedRecordInContent(object RecordToFill)
        {
            LoanApplicationEditListModel EditingRecord = (LoanApplicationEditListModel)RecordToFill;
            tblLoanApplication           SaveModel     = DALObject.FindSaveModelByPrimeKey(EditingRecord.LoanApplicationID);

            if (SaveModel == null)
            {
                return;
            }

            deLoanApplicationDate.DateTime          = SaveModel.LoanApplicationDate;
            lookupLoanApplicationNoPrefix.EditValue = SaveModel.LoanApplicationNoPrefixID;
            txtLoanApplicationNo.EditValue          = SaveModel.LoanApplicationNo;
            lookupEmployee.EditValue = SaveModel.EmployeeID;

            deDateFrom.DateTime = new DateTime(SaveModel.YearFrom, SaveModel.MonthFrom, 1);
            deDateTo.DateTime   = new DateTime(SaveModel.YearTo, SaveModel.MonthTo, 1);

            txtLoanAmount.EditValue = SaveModel.LoanAmount;
            InstallmentAmount       = SaveModel.InstallmentAmount;

            txtLoanPurpose.Text = SaveModel.LoanPurpose;
            txtRemarks.Text     = SaveModel.Remarks;
            txtDocument.Text    = SaveModel.ApplicationDocumentFileName;

            base.FillSelectedRecordInContent(RecordToFill);
        }
Esempio n. 3
0
        public SavingResult SaveNewRecord(tblLoanApplication SaveModel)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblLoanApplication SaveModel;
                if (SaveModel.LoanApplicationNo == 0)
                {
                    res.ValidationError = "Please enter Loan Application No.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.LoanApplicationNoPrefixID, SaveModel.LoanApplicationNo, SaveModel.LoanApplicationID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The Loan Application No. is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                if (SaveModel.LoanApplicationID == 0) // New Entry
                {
                    SaveModel.rcuid       = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.rcdt        = DateTime.Now;
                    SaveModel.CompanyID   = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID;
                    SaveModel.FinPeriodID = Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID;
                    db.tblLoanApplications.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblLoanApplications.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.LoanApplicationID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
        public void Create_AddAnotherLoanApplication_LoanApplicationCreated()
        {
            var loan = new tblLoanApplication
            {
                Name   = "Kamal",
                Amount = 300,
            };

            LoanService.CreteLoan(loan);
            var result = LoanService.GetLoan(loan.Id);

            (result.Name).Should().Be("Kamal");
        }
        static void Main(string[] args)
        {
            var kernel = new StandardKernel();

            kernel.Bind <ILoanService>().To <LoanService>();
            kernel.Bind <ILoanApplicationUnitOfWork>().To <LoanApplicationUnitOfWork>();
            var loanService = kernel.Get <ILoanService>();
            var result      = loanService.GetLoan(1);

            Console.WriteLine(result.Name);
            var loan = new tblLoanApplication
            {
                Name   = "Test",
                Amount = 3400,
                Id     = 3434
            };

            loanService.CreteLoan(loan);
        }
        public void Get_AddTwoLoans_CorrectLoanIsRetrived()
        {
            var loan1 = new tblLoanApplication
            {
                Id     = 1,
                Name   = "sumon",
                Amount = 25000
            };
            var loan2 = new tblLoanApplication
            {
                Id     = 2,
                Name   = "Kamal",
                Amount = 3580
            };

            _mockLoanApplications.SetSource(new[] { loan1, loan2 });
            var result = _loanApplicationRespository.Get(c => c.Id == 1);

            (result).Should().NotBeNull();
            (result.Amount).Should().Be(25000);
        }
        public void Create_AddALoanApplication_LoanApplicationCreated()
        {
            var firstLoan = new tblLoanApplication
            {
                Amount = 33434,
                Name   = "Mostofa"
            };

            LoanUnitOfWork.Repository <tblLoanApplication>().Add(firstLoan);
            LoanUnitOfWork.SaveChanges();
            var loan = new tblLoanApplication
            {
                Name   = "Sumon",
                Amount = 4509,
            };

            LoanService.CreteLoan(loan);
            var result = LoanService.GetLoan(loan.Id);

            (result.Amount).Should().Be(4509);
        }
Esempio n. 8
0
        public SavingResult DeleteRecord(long DeleteID)
        {
            SavingResult res = new SavingResult();

            using (dbVisionEntities db = new dbVisionEntities())
            {
                if (DeleteID != 0)
                {
                    tblLoanApplication RecordToDelete = db.tblLoanApplications.FirstOrDefault(r => r.LoanApplicationID == DeleteID);

                    if (RecordToDelete == null)
                    {
                        res.ValidationError = "Selected record not found. May be it has been deleted by another user over network.";
                        res.ExecutionResult = eExecutionResult.ValidationError;
                        return(res);
                    }
                    else
                    {
                        //db.tblLoanApplications.Remove(RecordToDelete);
                        byte RecordState_Deleted = (byte)eRecordState.Deleted;
                        RecordToDelete.rstate = RecordState_Deleted;
                        db.tblLoanApplications.Attach(RecordToDelete);
                        db.Entry(RecordToDelete).State = System.Data.Entity.EntityState.Modified;
                    }

                    try
                    {
                        db.SaveChanges();
                        res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                    }
                    catch (Exception ex)
                    {
                        CommonFunctions.GetFinalError(res, ex);
                    }
                }
            }
            return(res);
        }
 public void CreteLoan(tblLoanApplication loan)
 {
     _uow.Repository <tblLoanApplication>().Add(loan);
     _uow.SaveChanges();
 }
Esempio n. 10
0
        public override void SaveRecord(SavingParemeter Paras)
        {
            DAL.tblLoanApplication SaveModel = null;
            if (Paras.SavingInterface == SavingParemeter.eSavingInterface.AddNew || EditRecordDataSource == null)
            {
                SaveModel = new tblLoanApplication();
            }
            else
            {
                SaveModel = DALObject.FindSaveModelByPrimeKey(((LoanApplicationEditListModel)EditRecordDataSource).LoanApplicationID);

                if (SaveModel == null)
                {
                    Paras.SavingResult = new SavingResult();
                    Paras.SavingResult.ExecutionResult = eExecutionResult.ValidationError;
                    Paras.SavingResult.ValidationError = "Can not edit. Selected record not found, it may be deleted by another user.";
                    return;
                }
            }

            SaveModel.LoanApplicationDate       = deLoanApplicationDate.DateTime.Date;
            SaveModel.LoanApplicationNoPrefixID = (int)lookupLoanApplicationNoPrefix.EditValue;
            SaveModel.LoanApplicationNo         = Model.CommonFunctions.ParseInt(txtLoanApplicationNo.Text);
            SaveModel.EmployeeID = (int)lookupEmployee.EditValue;

            SaveModel.MonthFrom = deDateFrom.DateTime.Month;
            SaveModel.YearFrom  = deDateFrom.DateTime.Year;
            SaveModel.MonthTo   = deDateTo.DateTime.Month;
            SaveModel.YearTo    = deDateTo.DateTime.Year;

            SaveModel.LoanAmount        = Model.CommonFunctions.ParseDecimal(txtLoanAmount.Text);
            SaveModel.InstallmentAmount = InstallmentAmount;

            SaveModel.LoanPurpose = txtLoanPurpose.Text;
            SaveModel.Remarks     = txtRemarks.Text;

            // if new record or document has been changed then update it.
            if (Paras.SavingInterface == SavingParemeter.eSavingInterface.AddNew || SaveModel.ApplicationDocumentFileName != txtDocument.Text)
            {
                SaveModel.ApplicationDocumentFileName = null;
                if (!String.IsNullOrWhiteSpace(txtDocument.Text) && System.IO.File.Exists(txtDocument.Text))
                {
                    string DocumentNewPath     = Path.GetFullPath(Path.Combine(CommonProperties.LoginInfo.SoftwareSettings.DocumentLocation_LoanApplicationDocument));
                    string DocumentNewFileName = Path.Combine(DocumentNewPath,
                                                              "LAD" + CommonProperties.LoginInfo.LoggedInCompany.CompanyID.ToString("000") + CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID.ToString("000") +
                                                              SaveModel.LoanApplicationNo.ToString("0000000000") + Path.GetExtension(txtDocument.Text));
                    try
                    {
                        if (!Directory.Exists(DocumentNewPath))
                        {
                            Directory.CreateDirectory(DocumentNewPath);
                        }
                        // Allow to overwrite the document only if in edit mode
                        File.Copy(txtDocument.Text, DocumentNewFileName, (SaveModel.LoanApplicationID != 0));
                    }
                    catch (System.IO.IOException ex)
                    {
                        SavingResult res = new SavingResult();
                        DAL.CommonFunctions.GetFinalError(res, ex);
                        Paras.SavingResult = res;
                        return;
                    }
                    SaveModel.ApplicationDocumentFileName = DocumentNewFileName;
                }
            }

            Paras.SavingResult = DALObject.SaveNewRecord(SaveModel);

            base.SaveRecord(Paras);
        }