Пример #1
0
        //public int Payemi(LoanTransactionEntity e)
        //{
        //    var res = from t in ob.LoanAccounts
        //              where t.LoanAcid == e.loanAcid
        //              select t;

        //    int loantransid;
        //    var lasttrans = ob.LoanTransactions.OrderByDescending(c => c.transactionNo).FirstOrDefault();
        //    if (lasttrans == null)
        //    {
        //        loantransid = 10000;
        //    }
        //    else
        //    {
        //        loantransid = 1 + Convert.ToInt32(lasttrans.transactionNo);
        //    }
        //    if (res.Count() > 0)
        //    {


        //        (from t in ob.LoanAccounts
        //         where t.LoanAcid == e.loanAcid
        //         select t).ToList().ForEach(x => x.Emi = x.Emi - e.Amount);
        //        int b;
        //        var j = (from t in ob.LoanAccounts
        //                 where t.LoanAcid == e.loanAcid
        //                 select t).Single();


        //        b = (int)(Convert.ToInt32(j) - e.Amount);


        //        LoanTransaction k = new LoanTransaction() { transactionNo = loantransid, Amount = e.Amount, loanAcid = e.loanAcid, EmiDate = DateTime.Now, Outstanding = b - e.Amount };
        //        ob.LoanTransactions.Add(k);
        //        return ob.SaveChanges();
        //    }
        //    else
        //    {
        //        return 0;
        //    }
        //}



        public int payemi(LoanTransactionEntity lt, String lacid)
        {
            var res = (from c in ob.LoanAccounts
                       where c.LoanAcid == lacid
                       select c);
            var am = (from c in ob.LoanAccounts
                      where c.LoanAcid == lacid
                      select c.LoanAmount).SingleOrDefault();

            int b = Convert.ToInt32(am);

            if (res.Count() > 0)
            {
                int    os;
                string transno;
                var    tn   = ob.LoanTransactions.OrderByDescending(t => t.transactionNo).FirstOrDefault();
                var    last = ob.LoanTransactions.Where(t => t.loanAcid == lacid).OrderBy(t => t.Outstanding).FirstOrDefault();


                if (tn == null)
                {
                    transno = "10001";
                }
                else
                {
                    transno = (Convert.ToInt32(tn.transactionNo) + 1).ToString();
                }

                if (last == null)
                {
                    os = (int)(am - lt.Amount);
                }
                else
                {
                    os = ((int)(Convert.ToInt32(last.Outstanding) - lt.Amount));
                }


                LoanTransaction lnt = new LoanTransaction {
                    transactionNo = Convert.ToInt32(transno), loanAcid = lacid, EmiDate = DateTime.Now, Amount = lt.Amount, Outstanding = os
                };


                ob.LoanTransactions.Add(lnt);
                ob.SaveChanges();
            }
            else
            {
                return(0);
            }
            return(1);
        }
Пример #2
0
        public ActionResult Payemi(LoanTransactionEntity lt, String lacid)
        {
            int res = ob.payemi(lt, lacid);

            if (ModelState.IsValid)
            {
                if (res > 0)
                {
                    ViewData["status"] = "Emi Paid Successfully";
                }
                else
                {
                    ViewData["status"] = "The Loan Id doesnot Exist ";
                }
                return(View());
            }
            else
            {
                return(View());
            }
        }
Пример #3
0
 public int payemi(LoanTransactionEntity lt, String lacid)
 {
     return(ob.payemi(lt, lacid));
 }