コード例 #1
0
        private void Update()
        {
            newEntity                   = new LoanEntity();
            newEntity.Amount            = Convert.ToDecimal(this.txtAmount.Text.Trim());
            newEntity.Period            = Convert.ToInt32(txtPeriod.Text.Trim());
            newEntity.ID                = loanid;
            newEntity.CollateralId      = Convert.ToInt32(ddlCollateral.SelectedValue);
            newEntity.CollateralDetails = this.txtCollateralDetails.Text.Trim();
            newEntity.ComakerId         = 0;
            newEntity.Date              = DateTime.Now; //set dummy value to prevent error
            newEntity.Notes             = this.txtNotes.Text.Trim();
            newEntity.Penalty           = 0;
            newEntity.PenaltyDetails    = string.Empty;

            newService.SaveApplyLoan(ActionType.Update, newEntity);

            if (this.userid >= 0)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                Response.Redirect("AdminDefault.aspx");
            }
        }
コード例 #2
0
        private void PopulateFields(int id)
        {
            newEntity = new LoanEntity();
            newEntity = newService.GetApplyLoan(id);

            txtPeriod.Text = newEntity.Period.ToString();
            //ddlLoanTerm.SelectedValue = newEntity.TermId.ToString();
            //this.txtDate.Text = newEntity.Date.ToString("yyyy-MM-dd");
            //this.txtInterest.Text = newEntity.Interest.ToString();
            ddlCollateral.SelectedValue    = newEntity.CollateralId.ToString();
            this.txtCollateralDetails.Text = newEntity.CollateralDetails;
            //ddlBorrower.SelectedValue = newEntity.BorrowerId.ToString();
            this.txtNotes.Text  = newEntity.Notes;
            this.txtAmount.Text = newEntity.Amount.ToString();
            //this.txtPenalty.Text = newEntity.Penalty.ToString();
            //this.txtPenaltyDetails.Text = newEntity.PenaltyDetails;

            //LoadComaker(newEntity.BorrowerId);
            //ddlComaker.SelectedValue = newEntity.ComakerId.ToString();

            //LoadInvestors(-1);
            //ddlInvestor.SelectedValue = newEntity.InvestorId.ToString();

            //ddlLoanTerm.Enabled = false;
            //ddlComaker.Enabled = false;
            //ddlBorrower.Enabled = false;
            //ddlInvestor.Enabled = false;
            //txtDate.Enabled = false;
            //txtInterest.Enabled = false;
            //this.txtAmount.Enabled = false;
            //txtPeriod.Enabled = false;
        }
コード例 #3
0
        public void AddLoan()
        {
            if (SelectedOrderline != null && SelectedOrderline.OrderId > 0 && RelatedArticle != null && RelatedArticle.ArticleId > 0)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                        LoanEntity newEntity = new LoanEntity()
                        {
                            OrderlineId       = SelectedOrderline.OrderlineId,
                            ArticleId         = RelatedArticle.ArticleId,
                            Quantity          = 0,
                            RemainingQuantity = 0
                        };
                        var updatedEntity = Factory.Resolve <IBaseDataDS>().AddOrUpdateLoan(newEntity);

                        HideLoading();

                        //display to UI
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            AddOrUpdateLoanToList(updatedEntity);
                        }));
                    }
                    catch (Exception ex)
                    {
                        HideLoading();
                        ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                    }
                });
            }
        }
コード例 #4
0
ファイル: LoanRepository.cs プロジェクト: suelinton/loanGames
        public LoanEntity Add(LoanEntity loan)
        {
            _context.Add(loan);
            _context.SaveChanges();

            return(loan);
        }
コード例 #5
0
        public LoanEntity GetApplyLoan(int loanid)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    string    sql;
                    int       ret    = 0;
                    DataTable oTable = new DataTable();
                    sql = "GetApplyLoan";
                    db.ExecuteCommandReader(sql,
                                            new string[] { "@id" },
                                            new DbType[] { DbType.Int32 },
                                            new object[] { loanid },
                                            out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    LoanEntity user = new LoanEntity();
                    if (oTable.Rows.Count > 0)
                    {
                        DataRow oRow = oTable.Rows[0];
                        user = SetApplyLoanData(oRow);
                    }

                    return(user);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        private LoanEntity SetData(DataRow oRow)
        {
            try
            {
                LoanEntity ent = new LoanEntity();
                ent.ID                = Convert.ToInt32(oRow["id"]);
                ent.Amount            = Convert.ToDecimal(oRow["amount"]);
                ent.Period            = Convert.ToInt32(oRow["period"]);
                ent.TermId            = Convert.ToInt32(oRow["term_id"]);
                ent.Date              = Convert.ToDateTime(oRow["date"]);
                ent.Interest          = Convert.ToDecimal(oRow["interest"]);
                ent.CollateralId      = Convert.ToInt32(oRow["collateral_id"]);
                ent.CollateralDetails = oRow["collateral_details"].ToString();
                ent.ComakerId         = Convert.ToInt32(oRow["comaker_id"]);
                ent.BorrowerId        = Convert.ToInt32(oRow["borrower_id"]);
                ent.InvestorId        = Convert.ToInt32(oRow["investor_id"]);
                ent.Notes             = oRow["notes"].ToString();
                ent.Penalty           = Convert.ToDecimal(oRow["penalty"]);
                ent.PenaltyDetails    = oRow["penalty_details"].ToString();
                ent.Status            = Convert.ToInt32(oRow["status"]);

                return(ent);
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #7
0
        public void DeleteLoan(LoanEntity entityObject)
        {
            if (ShowMessageBox(StringResources.captionConfirm, StringResources.msgConfirmDelete, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                        var isSuccess = Factory.Resolve <IOrderDS>().DeleteLoan(entityObject);

                        HideLoading();

                        //display to UI
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            if (isSuccess)
                            {
                                DeleteLoanFromList(entityObject);
                            }
                        }));
                    }
                    catch (Exception ex)
                    {
                        HideLoading();
                        ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                    }
                });
            }
        }
コード例 #8
0
        public int AddLoan(int userID, int bookID)
        {
            // Check if user exists
            if (!db.Users.Where(u => u.ID == userID).Any())
            {
                throw new NotFoundException(userNotFoundMessage);
            }

            // Check if book exists
            if (!db.Books.Where(b => b.ID == bookID).Any())
            {
                throw new NotFoundException(bookNotFoundMessage);
            }

            // Check if user already has book loaned
            if (db.Loans.Where(l => l.BookID == bookID && l.UserID == userID && l.ReturnDate == null).Any())
            {
                throw new AlreadyExistsException(loanAlreadyExistsMessage);
            }

            var loanEntity = new LoanEntity
            {
                UserID     = userID,
                BookID     = bookID,
                LoanDate   = DateTime.Now,
                ReturnDate = null
            };

            // Add loan
            db.Loans.Add(loanEntity);
            db.SaveChanges();

            return(loanEntity.ID);
        }
コード例 #9
0
        public async Task UpdateLoanStatus(Guid loanId, LoanStatus loanStatus)
        {
            LoanEntity loanToUpdateStatus = await _loansContext.Loans
                                            .FirstOrDefaultAsync(l => l.ID == loanId);

            loanToUpdateStatus.LoanStatus = loanStatus;
            await _loansContext.SaveChangesAsync();
        }
コード例 #10
0
        public bool DeleteLoan(LoanEntity entityObject)
        {
            string sqlStatement = "DELETE FROM Loan WHERE LoanId=@LoanId  " + Environment.NewLine;

            //execute
            Connection.Execute(sqlStatement, new { LoanId = entityObject.LoanId }, Transaction);
            return(true);
        }
コード例 #11
0
        public LoanEntity AddOrUpdateLoan(LoanEntity entityObject)
        {
            string sqlStatement = "";

            sqlStatement += "DECLARE @NewLoanId INT " + Environment.NewLine;
            //if insert
            if (entityObject.LoanId > 0)
            {
                sqlStatement += "UPDATE Loan SET  " + Environment.NewLine +
                                //"OrderId=@OrderId" + Environment.NewLine +
                                "ArticleId=@ArticleId," + Environment.NewLine +
                                "Quantity=@Quantity" + Environment.NewLine +
                                "WHERE LoanId=@LoanId " + Environment.NewLine +
                                "SET @NewLoanId = @LoanId " + Environment.NewLine;
            }
            else
            {
                sqlStatement += "INSERT INTO Loan(  " + Environment.NewLine +
                                "OrderlineId," + Environment.NewLine +
                                "ArticleId," + Environment.NewLine +
                                "Quantity)" + Environment.NewLine +
                                "VALUES (" + Environment.NewLine +
                                "@OrderlineId," + Environment.NewLine +
                                "@ArticleId," + Environment.NewLine +
                                "@Quantity)" + Environment.NewLine +
                                "SET @NewLoanId = (SELECT SCOPE_IDENTITY()) " + Environment.NewLine;
            }

            sqlStatement += "SELECT " + Environment.NewLine +
                            "Loan.LoanId," + Environment.NewLine +
                            "Loan.Quantity," + Environment.NewLine +
                            "Loan.ArticleId," + Environment.NewLine +
                            "Article.CategoryId," + Environment.NewLine +
                            "Article.ArticleNo," + Environment.NewLine +
                            "Article.Description," + Environment.NewLine +
                            "Article.Unit " + Environment.NewLine +
                            "FROM Loan JOIN Article ON Loan.ArticleId=Article.ArticleId " + Environment.NewLine +
                            "WHERE Loan.LoanId=@NewLoanId" + Environment.NewLine;

            //execute
            var result = Connection.Query <LoanEntity>(sqlStatement, new
            {
                OrderlineId = entityObject.OrderlineId,
                ArticleId   = entityObject.ArticleId,
                Quantity    = entityObject.Quantity,
                LoanId      = entityObject.LoanId
            }, Transaction).ToList();

            if (result.Count > 0)
            {
                entityObject = result[0];
            }
            else
            {
                entityObject = null;
            }
            return(entityObject);
        }
コード例 #12
0
        public async Task UpdateApproveFailureRules(Guid loanId, List <LoanFailureRuleModel> loanFailureRules)
        {
            List <LoanFailureRulesEntity> approveFailureRules = _mapper.Map <List <LoanFailureRulesEntity> >(loanFailureRules);
            LoanEntity loanEntity = await _loansContext.Loans
                                    .FirstOrDefaultAsync(l => l.ID == loanId);

            loanEntity.FailureRules = approveFailureRules;
            await _loansContext.SaveChangesAsync();
        }
コード例 #13
0
        void ChildList_AddingNew(object sender, AddingNewEventArgs e)
        {
            var newObject = new LoanEntity()
            {
                OrderlineId = -1
            };

            e.NewObject = newObject;
        }
コード例 #14
0
        public async Task <LoanModel> GetLoanById(Guid loanId)
        {
            LoanEntity loanEntity = await _loansContext.Loans
                                    .FirstOrDefaultAsync(l => l.ID == loanId);

            LoanModel loan = _mapper.Map <LoanModel>(loanEntity);

            return(loan);
        }
コード例 #15
0
        public async Task <List <LoanFailureRuleModel> > GetFailureRulesByLoanId(Guid loanId)
        {
            LoanEntity loanEntity = await _loansContext.Loans
                                    .Include(l => l.FailureRules)
                                    .FirstOrDefaultAsync(l => l.ID == loanId);

            List <LoanFailureRuleModel> loanFailureRules = _mapper.Map <List <LoanFailureRuleModel> >(loanEntity.FailureRules);

            return(loanFailureRules);
        }
コード例 #16
0
        public void DeleteLoanFromList(LoanEntity newEntity)
        {
            LoanEntity oldEntity = LoanList.FirstOrDefault <LoanEntity>(p => p.LoanId == newEntity.LoanId);

            if (oldEntity != null)
            {
                LoanList.Remove(oldEntity);
            }

            LoanList = new List <LoanEntity>(_loanList);
        }
コード例 #17
0
        public async Task UpdateLoanFailureRules(Guid loanId, List <LoanFailureRulesModel> failureRules)
        {
            LoanEntity loanToUpdateFailureRules = await _loansContext.Loans
                                                  .FirstOrDefaultAsync(l => l.ID == loanId);

            List <LoanFailureRulesEntity> loanFailureRules = _mapper.Map <List <LoanFailureRulesEntity> >(failureRules);

            loanToUpdateFailureRules.FailureRules = new List <LoanFailureRulesEntity>();
            loanToUpdateFailureRules.FailureRules.AddRange(loanFailureRules);
            await _loansContext.SaveChangesAsync();
        }
コード例 #18
0
        public async Task <bool> CheckLoanExist(Guid loanId)
        {
            LoanEntity loanEntity = await _loansContext.Loans
                                    .FirstOrDefaultAsync(l => l.ID == loanId);

            if (loanEntity == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #19
0
 public override Loan MapToDomain(LoanEntity loan)
 {
     return(new VipLoan
     {
         Id = loan.Id,
         CustomerId = loan.CustomerId,
         InterestRate = loan.InterestRate,
         LoanAmount = loan.LoanAmount,
         LoanStart = loan.LoanStart,
         LoanEnd = loan.LoanEnd
     });
 }
コード例 #20
0
        public async Task <Guid> Create(LoanModel loanModel)
        {
            //now, I assume that provider loan id exists
            LoanEntity loanEntity = _mapper.Map <LoanEntity>(loanModel);

            loanEntity.ID       = Guid.NewGuid();
            loanEntity.LoanDate = DateTime.Now;
            await _loansContext.AddAsync(loanEntity);

            await _loansContext.SaveChangesAsync();

            return(loanEntity.ID);
        }
コード例 #21
0
        public async Task <Guid> Create(LoanModel loanModel)
        {
            //האם לבדוק אם ספק ההלוואה קיים?//מסתמכת על ספקים קבועים במאגר
            LoanEntity loanEntity = _mapper.Map <LoanEntity>(loanModel);

            loanEntity.ID       = Guid.NewGuid();
            loanEntity.LoanDate = DateTime.Now;
            await _loansContext.AddAsync(loanEntity);

            await _loansContext.SaveChangesAsync();

            return(loanEntity.ID);
        }
コード例 #22
0
        public async Task Update(Guid loanId, LoanModel loanModel)
        {
            LoanEntity loanEntity   = _mapper.Map <LoanEntity>(loanModel);
            LoanEntity loanToUpdate = await _loansContext.Loans
                                      .FirstOrDefaultAsync(l => l.ID == loanId);

            loanToUpdate.LoanAmount           = loanEntity.LoanAmount;
            loanToUpdate.Salary               = loanEntity.Salary;
            loanToUpdate.FixedSalary          = loanEntity.FixedSalary;
            loanToUpdate.LoanPurpose          = loanEntity.LoanPurpose;
            loanToUpdate.NumberOfRepayments   = loanEntity.NumberOfRepayments;
            loanToUpdate.SeniorityYearsInBank = loanEntity.SeniorityYearsInBank;
            loanToUpdate.LoanStatus           = loanEntity.LoanStatus;
            await _loansContext.SaveChangesAsync();
        }
コード例 #23
0
        private void Update()
        {
            newEntity                   = new LoanEntity();
            newEntity.ID                = id;
            newEntity.CollateralId      = Convert.ToInt32(ddlCollateral.SelectedValue);
            newEntity.CollateralDetails = this.txtCollateralDetails.Text.Trim();
            newEntity.ComakerId         = Convert.ToInt32(ddlComaker.SelectedValue);
            newEntity.Date              = DateTime.Now; //set dummy value to prevent error
            newEntity.Notes             = this.txtNotes.Text.Trim();
            newEntity.Penalty           = string.IsNullOrEmpty(this.txtPenalty.Text) ? 0 : Convert.ToDecimal(this.txtPenalty.Text);
            newEntity.PenaltyDetails    = this.txtPenaltyDetails.Text.Trim();

            newService.Save(ActionType.Update, newEntity);

            Response.Redirect("ManageLoans.aspx");
        }
コード例 #24
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="T:Albaraka.Utils.Calculator.LoanCalculator.DetailedLoanCalculator"/> class.
        /// </summary>
        /// <param name="loanEntity">Loan entity.</param>
        /// <param name="culture">Culture.</param>
        public DetailedLoanCalculator(LoanEntity loanEntity, CultureInfo culture)
        {
            if (this.loanEntity == null)
            {
                throw new ArgumentException(message: "Empty Argument: logEntry!");
            }
            this.loanEntity = loanEntity;

            if (culture == null)
            {
                this.culture = new CultureInfo("tr-TR");
            }
            else
            {
                this.culture = culture;
            }
        }
コード例 #25
0
        /// <summary>
        /// Calculates the installments.
        /// Taksit Listesi Oluştur
        /// </summary>
        /// <returns>The installments.</returns>
        /// <param name="loanEntity">Loan entity.</param>
        public LoanEntity CalculateInstallments(LoanEntity loanEntity)
        {
            //Katkı Paylı Hesaplama
            if (loanEntity.CIncentiveAmount > 0 || loanEntity.CIncentiveRate > 0 || loanEntity.CIncentiveAppliedProfitRate != null)
            {
                loanEntity = CalculateInstallmentsWithIncentive(loanEntity);
            }
            //Katkı Paysız Normal Hesaplama
            else
            {
                ////////////////////////////////////////////////////////
                loanEntity = PrepareScheduleTable(loanEntity);
                ////////////////////////////////////////////////////////
                loanEntity.CAppliedProfitRate = loanEntity.CProfitRate;
            }

            return(loanEntity);
        }
コード例 #26
0
        public virtual void Issue1369Test()
        {
            using (var ctx = new Issue1369Context())
            {
                ctx.Database.CreateIfNotExists();

                var loan = new LoanEntity
                {
                    Id = Guid.NewGuid(),
                    MarketplaceLoanId   = "x",
                    MarketplaceMemberId = "x",
                    LoanAmount          = 12,
                    FundedAmount        = 12,
                    InterestRate        = 100,
                    ExpectedDefaultRate = 100,
                    ServiceFeeRate      = 10,
                    Grade                = "x",
                    Subgrade             = "x",
                    HomeOwnership        = "x",
                    AnnualIncome         = 123,
                    ReviewStatus         = "x",
                    Url                  = "x",
                    Purpose              = "x",
                    Title                = "x",
                    City                 = "x",
                    State                = "x",
                    InitialListingStatus = "x",
                    ListDate             = DateTime.Now,
                    CreditPullDate       = DateTime.Now,
                    EffectiveDate        = DateTime.Now,
                    CreditReports        = new List <CreditReportEntity> {
                        new CreditReportEntity
                        {
                            Id = Guid.NewGuid()
                        }
                    }
                };
                var loans = new[] { loan };

                ctx.BulkInsert(loans, BulkCopyOptions.KeepIdentity);
            }
        }
コード例 #27
0
        private LoanEntity SetApplyLoanData(DataRow oRow)
        {
            try
            {
                LoanEntity ent = new LoanEntity();
                ent.ID     = Convert.ToInt32(oRow["id"]);
                ent.Amount = Convert.ToDecimal(oRow["amount"]);
                ent.Period = Convert.ToInt32(oRow["period"]);

                ent.CollateralId      = Convert.ToInt32(oRow["collateral_id"]);
                ent.CollateralDetails = oRow["collateral_details"].ToString();

                ent.BorrowerId = Convert.ToInt32(oRow["borrower_id"]);

                ent.Notes = oRow["notes"].ToString();


                return(ent);
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #28
0
        public void AddOrUpdateLoanToList(LoanEntity newEntity)
        {
            if (LoanList == null)
            {
                LoanList = new List <LoanEntity>();
            }

            LoanEntity oldEntity = LoanList.FirstOrDefault <LoanEntity>(p => p.LoanId == newEntity.LoanId);

            if (oldEntity == null)
            {
                LoanList.Insert(0, newEntity);
            }
            else
            {
                int index = LoanList.IndexOf(oldEntity);
                LoanList.Remove(oldEntity);
                LoanList.Insert(index, newEntity);
            }

            LoanList = new List <LoanEntity>(_loanList);
        }
コード例 #29
0
        public void SaveLoan(LoanEntity entityObject)
        {
            if (entityObject != null && entityObject.LoanId > 0)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                        var updatedEntity = Factory.Resolve <IOrderDS>().AddOrUpdateLoan(entityObject);

                        HideLoading();
                    }
                    catch (Exception ex)
                    {
                        HideLoading();
                        ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                    }
                });
            }
        }
コード例 #30
0
        private void Create()
        {
            newEntity = new LoanEntity();

            newEntity.Amount            = Convert.ToDecimal(this.txtAmount.Text.Trim());
            newEntity.Period            = Convert.ToInt32(txtPeriod.Text.Trim());
            newEntity.TermId            = 0;
            newEntity.Date              = DateTime.Now;
            newEntity.Interest          = 6;
            newEntity.CollateralId      = Convert.ToInt32(ddlCollateral.SelectedValue);
            newEntity.CollateralDetails = this.txtCollateralDetails.Text.Trim();
            newEntity.ComakerId         = 0;
            newEntity.BorrowerId        = this.userid;
            newEntity.InvestorId        = 0;
            newEntity.Notes             = this.txtNotes.Text.Trim();
            newEntity.Penalty           = 0;
            newEntity.PenaltyDetails    = string.Empty;
            newEntity.Status            = 0;

            newService.SaveApplyLoan(ActionType.Create, newEntity);

            Response.Redirect("Default.aspx");
        }