示例#1
0
        public string Post([FromBody] LoanApprover loanApprover)
        {
            loanApprover.newApplication.status           = "success";
            hle.Entry(loanApprover.newApplication).State = System.Data.Entity.EntityState.Modified;
            hle.SaveChanges();

            loan       newLoan    = new loan();
            loanDetail newloandet = new loanDetail();

            newloandet = hle.loanDetails.ToList().Find(item => item.appId == loanApprover.newApplication.appId);

            newLoan.adminId        = loanApprover.adminId;
            newLoan.remarks        = loanApprover.remarks;
            newLoan.loanId         = loanApprover.newApplication.appId;
            newLoan.status         = "current";
            newLoan.loanDateStart  = System.DateTime.Now;
            newLoan.amountApproved = newloandet.loanAsked;
            newLoan.noOfEmiTotal   = hle.loanDetails.ToList().Find(item => item.appId == newLoan.loanId).tenure * 12;
            newLoan.noOfEmiLeft    = newLoan.noOfEmiTotal;

            hle.loans.Add(newLoan);
            hle.SaveChanges();


            return("loan has been approved");
        }
示例#2
0
        public static void loanToUser(loanDetail l)
        {
            using (var context = new STOK_TAKIPEntities())
            {
                //get sql parameters for addLoan procedure
                var userID    = new SqlParameter("@userID", l.userID);
                var loanByID  = new SqlParameter("@loanByID", l.loanByID);
                var productID = new SqlParameter("@productID", l.productID);
                var loanDate  = new SqlParameter("@loanDate", l.loanDate);
                var pieces    = new SqlParameter("@loanPieces", l.loanPieces);

                try
                {
                    //execute addLoan stored procedure
                    context.Database.ExecuteSqlCommand("exec addLoan @userID , @loanByID , @productID , @loanDate, @loanPieces",
                                                       userID, loanByID, productID, loanDate, pieces);
                    MessageBox.Show("The transaction (Loan) was successful!");
                    ucLoans.Instance           = null;
                    ucProduct.Instance         = null;
                    ucRemoveProduct.Instance   = null;
                    ucUndoProduct.Instance     = null;
                    ucDepartmentChief.Instance = null;
                }
                catch
                {
                    MessageBox.Show("The transaction (Loan) was failed!");
                }
            }
        }
示例#3
0
        private void btnAddLoan_Click(object sender, EventArgs e)
        {
            if (txtPiece.Text == "" || cbUser.SelectedIndex == -1 || string.IsNullOrWhiteSpace(cbProducts.Text.ToString()))
            {
                MessageBox.Show("You must fill in the required fields");
            }
            else
            {
                if (int.Parse(lblAvailable.Text) >= int.Parse(txtPiece.Text))
                {
                    // Zimmetleme işlemleri burada gerçekleştiriliyor
                    string[]   user    = cbUser.SelectedItem.ToString().Split('-');
                    string[]   product = cbProducts.SelectedItem.ToString().Split('-');
                    var        result  = productList.Find(x => x.productName == cbProducts.SelectedItem.ToString());
                    loanDetail l       = new loanDetail();
                    product    p       = new product();
                    l.productID  = result.productID;
                    l.loanDate   = DateTime.Now.ToString();
                    l.userID     = int.Parse(user[0]);
                    l.loanPieces = int.Parse(txtPiece.Text);
                    l.loanByID   = 1;

                    //Send Loan Controller
                    Controller.LoanController.loanToUser(l);
                    txtPiece.Text        = "";
                    cbUser.SelectedIndex = -1;
                }
                else
                {
                    MessageBox.Show("You can't write more than the maximum number of products!");
                }
            }
        }
示例#4
0
        public void loanToUser()
        {
            loanDetail loanDetail = new loanDetail
            {
                loanByID   = 1,
                loanDate   = DateTime.Now.ToString(),
                loanPieces = 5,
                productID  = 2,
                userID     = 44,
            };

            LoanController.loanToUser(loanDetail);
        }