Пример #1
0
        public ActionResult AddPayment(LoanHistory collection)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                try
                {
                    LoanHistory history = new LoanHistory();
                    history.CreationDate = DateTime.Now;
                    history.ModifyDate = DateTime.Now;
                    history.Version = 1;
                    history.LoanId = collection.Id;
                    history.DatePaid = collection.DatePaid;
                    history.BasicPayment = collection.BasicPayment;
                    history.AddPayment = collection.AddPayment;
                    history.Interest = collection.Interest;
                    history.Escrow = collection.Escrow;
                    history.PaymentTypeId = collection.PaymentTypeId;

                    Loan loan = context.GetLoan(history.LoanId);
                    loan.LoanHistories.Add(history);

                    context.SubmitChanges();

                    return RedirectToAction("Edit", new { id = history.LoanId });
                }
                catch
                {
                    return View(collection);
                }
            }
        }
Пример #2
0
        public ActionResult Add(Loan collection)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                try
                {
                    Loan loan = new Loan();
                    loan.CreationDate = DateTime.Now;
                    loan.ModifyDate = DateTime.Now;
                    loan.Version = 1;
                    loan.UserId = 1;
                    loan.PaymentTypeId = 4;
                    loan.IsActive = true;

                    loan.Name = collection.Name;
                    loan.FirstPaymentDate = collection.FirstPaymentDate;
                    loan.LoanAmount = collection.LoanAmount;
                    loan.InterestRate = collection.InterestRate;
                    loan.Term = collection.Term;
                    loan.AddPayment = collection.AddPayment;
                    loan.Escrow = collection.Escrow;
                    loan.InterestCompDaily = false;
                    loan.InterestCompMonthly = true;

                    context.Loans.InsertOnSubmit(loan);
                    context.SubmitChanges();

                    return RedirectToAction("Index");
                }
                catch
                {
                    return View(collection);
                }
            }
        }
Пример #3
0
        public ActionResult Add(Bill collection)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                try
                {
                    Bill bill = new Bill();
                    bill.CreationDate = DateTime.Now;
                    bill.ModifyDate = DateTime.Now;
                    bill.Version = 1;
                    bill.UserId = 1;
                    bill.PaymentTypeId = 4;
                    bill.IsActive = true;

                    bill.Amount = collection.Amount;
                    bill.DueDate = collection.DueDate;
                    bill.IssueDate = collection.IssueDate;
                    bill.Name = collection.Name;
                    bill.Payee = collection.Payee;
                    bill.Shared = collection.Shared;
                    bill.StaysSame = collection.StaysSame;

                    context.Bills.InsertOnSubmit(bill);
                    context.SubmitChanges();

                    return RedirectToAction("Index");
                }
                catch
                {
                    return View(collection);
                }
            }
        }
Пример #4
0
        public ActionResult AddPayment(BillHistory collection)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                try
                {
                    BillHistory history = new BillHistory();
                    history.CreationDate = DateTime.Now;
                    history.ModifyDate = DateTime.Now;
                    history.Version = 1;
                    history.BillId = collection.Id;

                    Bill bill = context.GetBill(history.BillId);
                    history.Bill = bill;

                    history.Amount = collection.Amount;
                    history.DatePaid = collection.DatePaid;
                    history.Payee = collection.Payee;
                    history.PaymentTypeId = collection.PaymentTypeId;
                    history.IssueDate = collection.IssueDate;

                    bill.BillHistories.Add(history);

                    if (bill.StaysSame || bill.BillHistoryAverage == null)
                    {
                        bill.DueDate = bill.DueDate.AddMonths(1);
                    }
                    else
                    {
                        IEnumerable<BillHistoryAverage> bha = bill.BillHistoryAverage.Where(x => x.Month.Month == bill.DueDate.AddMonths(1).Month);
                        if (bha.Any())
                        {
                            bill.DueDate = bha.FirstOrDefault().Month;
                            bill.Amount = bha.FirstOrDefault().Average;
                        }
                        else
                        {
                            bill.DueDate = bill.DueDate.AddMonths(1);
                        }
                    }

                    context.SubmitChanges();

                    return RedirectToAction("Edit", new { id = history.BillId });
                }
                catch
                {
                    return View(collection);
                }
            }
        }
Пример #5
0
        /* =========================
         * Bill History Functions
         * ========================= */
        public ActionResult AddPayment(int id)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                Bill bill = context.GetBill(id);

                BillHistory history = new BillHistory();
                history.Amount = bill.Amount;
                history.DatePaid = bill.DueDate;
                history.Payee = bill.Payee;
                history.PaymentTypeId = bill.PaymentTypeId;
                history.IssueDate = bill.IssueDate;
                history.Bill = bill;

                return View(history);
            }
        }
Пример #6
0
        /* =========================
         * Loan History Functions
         * ========================= */
        public ActionResult AddPayment(int id)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                Loan loan = context.GetLoan(id);
                LoanOutlook outlook = loan.LoanOutlook.FirstOrDefault();

                LoanHistory history = new LoanHistory();
                history.LoanId = loan.Id;
                history.BasicPayment = outlook.BaseAmount;
                history.AddPayment = outlook.AddAmount;
                history.Interest = outlook.InterestAmount;
                history.Escrow = outlook.EscrowAmount;
                history.DatePaid = outlook.Date;
                history.PaymentTypeId = loan.PaymentTypeId;
                history.Loan = loan;

                return View(history);
            }
        }
Пример #7
0
 public ActionResult View(int id)
 {
     ViewBag.Calculate = false;
     using (LinkToDBDataContext context = new LinkToDBDataContext())
     {
         return View(context.GetLoan(id));
     }
 }
Пример #8
0
 /* =========================
  * Loan Functions
  * ========================= */
 public ActionResult Index()
 {
     using (LinkToDBDataContext context = new LinkToDBDataContext())
     {
         return View(context.GetLoans().OrderBy(x => x.DueDate));
     }
 }
Пример #9
0
        public ActionResult EditPayment(BillHistory collection)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                BillHistory history = context.GetBillHistoryItem(collection.Id);

                try
                {
                    history.ModifyDate = DateTime.Now;
                    history.Version += 1;
                    history.DatePaid = collection.DatePaid;
                    history.Amount = collection.Amount;
                    history.Payee = collection.Payee;
                    history.IssueDate = collection.IssueDate;

                    context.SubmitChanges();

                    return RedirectToAction("Edit", new { id = history.BillId });
                }
                catch
                {
                    return View(history);
                }
            }
        }
Пример #10
0
 public ActionResult EditPayment(int id)
 {
     using (LinkToDBDataContext context = new LinkToDBDataContext())
     {
         BillHistory history = context.GetBillHistoryItem(id);
         history.Bill = context.GetBill(history.BillId);
         return View(history);
     }
 }
Пример #11
0
        public ActionResult Edit(int id, Loan collection, string button)
        {
            ViewBag.Calculate = false;
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                Loan loan = context.GetLoan(id);

                try
                {
                    loan.ModifyDate = DateTime.Now;
                    loan.Version += 1;
                    loan.Name = collection.Name;
                    loan.FirstPaymentDate = collection.FirstPaymentDate;
                    loan.LoanAmount = collection.LoanAmount;
                    loan.InterestRate = collection.InterestRate;
                    loan.Term = collection.Term;
                    loan.AddPayment = collection.AddPayment;
                    loan.Escrow = collection.Escrow;

                    switch (button)
                    {
                        case "Calculate":
                            loan = loan.LoadLoan();
                            ViewBag.Calculate = true;
                            return View(loan);
                        case "Save":
                            context.SubmitChanges();
                            return RedirectToAction("Index");
                        default:
                            return View(loan);
                    }
                }
                catch
                {
                    return View(loan);
                }
            }
        }
Пример #12
0
        public ActionResult Index()
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                DashboardViewModel viewModel = new DashboardViewModel();
                IEnumerable<Bill> bills = context.GetBills();
                IEnumerable<Loan> loans = context.GetLoans();

                DateTime startDate = DateTime.Now;
                foreach (Bill bill in bills) { startDate = (bill.DueDate <= startDate) ? bill.DueDate : startDate; }
                foreach (Loan loan in loans) { startDate = (loan.DueDate <= startDate) ? loan.DueDate : startDate; }
                if (startDate.Day > 1)
                {
                    //startDate = startDate.AddMonths(-1);
                    startDate = new DateTime(startDate.Year, startDate.Month, 1);
                }

                viewModel.DateRanges = InitiateDateRanges(startDate);

                foreach (DashboardDateRange range in viewModel.DateRanges)
                {
                    List<DashboardItem> items = new List<DashboardItem>();

                    foreach (Bill bill in bills) {
                        if (bill.DueDate >= range.StartDate && bill.DueDate <= range.EndDate) {
                            items.Add(new DashboardItem(bill));
                        }
                        if (bill.StaysSame || !bill.BillHistories.Any())
                        {
                            for (int i = 1; i <= 3; i++)
                            {
                                DateTime date = bill.DueDate.AddMonths(i);
                                if (date >= range.StartDate && date <= range.EndDate)
                                {
                                    DashboardItem item = new DashboardItem(bill);
                                    item.Date = date;
                                    item.IsPastDue = item.DueInDays < 0;
                                    items.Add(item);
                                }
                            }
                        }
                        else
                        {
                            Bill difBill = context.GetBill(bill.Id);
                            foreach (BillHistoryAverage bha in difBill.BillHistoryAverage)
                            {
                                if (bha.Month >= range.StartDate && bha.Month <= range.EndDate && bha.Month.Month != bill.DueDate.Month)
                                {
                                    DashboardItem item = new DashboardItem(bha);
                                    item.Id = bill.Id;
                                    item.Name = bill.Name;
                                    items.Add(item);
                                }
                            }
                        }

                        if (bill.BillHistories.Any())
                        {
                            foreach (BillHistory history in bill.BillHistory)
                            {
                                if (history.DatePaid >= range.StartDate && history.DatePaid <= range.EndDate)
                                {
                                    items.Add(new DashboardItem(history));
                                }
                            }
                        }
                    }

                    foreach (Loan loan in loans)
                    {
                        foreach (LoanOutlook outlook in loan.LoanOutlook)
                        {
                            if (outlook.Date >= range.StartDate && outlook.Date <= range.EndDate)
                            {
                                DashboardItem dbItem = new DashboardItem(outlook);
                                dbItem.Name = loan.Name;
                                dbItem.Id = loan.Id;
                                items.Add(dbItem);
                            }
                        }
                        foreach (LoanHistory history in loan.LoanHistory)
                        {
                            if (history.DatePaid >= range.StartDate && history.DatePaid <= range.EndDate)
                            {
                                items.Add(new DashboardItem(history));
                            }
                        }
                    }

                    range.Items = items.OrderBy(x => x.Date);
                }

                return View(viewModel);
            }
        }
Пример #13
0
 public ActionResult View(int id)
 {
     using (LinkToDBDataContext context = new LinkToDBDataContext())
     {
         return View(context.GetBill(id));
     }
 }
Пример #14
0
        public ActionResult Paid(int id)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                BillHistory history = new BillHistory();
                history.CreationDate = DateTime.Now;
                history.ModifyDate = DateTime.Now;
                history.Version = 1;
                history.BillId = id;

                Bill bill = context.GetBill(id);

                history.Amount = bill.Amount;
                history.DatePaid = bill.DueDate;
                history.Payee = bill.Payee;
                history.PaymentTypeId = bill.PaymentTypeId;
                history.IssueDate = bill.IssueDate;
                history.Bill = bill;

                if (bill.StaysSame || bill.BillHistoryAverage == null)
                {
                    bill.DueDate = bill.DueDate.AddMonths(1);
                }
                else
                {
                    IEnumerable<BillHistoryAverage> bha = bill.BillHistoryAverage.Where(x => x.Month.Month == bill.DueDate.AddMonths(1).Month);
                    if (bha.Any())
                    {
                        bill.DueDate = bha.FirstOrDefault().Month;
                        bill.Amount = bha.FirstOrDefault().Average;
                    }
                    else
                    {
                        bill.DueDate = bill.DueDate.AddMonths(1);
                    }
                }

                context.SubmitChanges();
                return RedirectToAction("Index", "Home", null);
            }
        }
Пример #15
0
 /* =========================
  * Bill Functions
  * ========================= */
 public ActionResult Index()
 {
     using (LinkToDBDataContext context = new LinkToDBDataContext())
     {
         return View(context.GetBills().Where(x => x.IsActive == true && x.DueInDays <= 45).OrderBy(x => x.DueDate));
     }
 }
Пример #16
0
        public ActionResult Edit(int id, Bill collection)
        {
            using (LinkToDBDataContext context = new LinkToDBDataContext())
            {
                Bill bill = context.GetBill(id);

                try
                {
                    bill.ModifyDate = DateTime.Now;
                    bill.Version += 1;
                    bill.Name = collection.Name;
                    bill.Payee = collection.Payee;
                    bill.DueDate = collection.DueDate;
                    bill.Amount = collection.Amount;
                    bill.IssueDate = collection.IssueDate;
                    bill.StaysSame = collection.StaysSame;
                    bill.Shared = collection.Shared;

                    context.SubmitChanges();

                    return RedirectToAction("Index");
                }
                catch
                {
                    return View(bill);
                }
            }
        }