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);
                }
            }
        }
Beispiel #2
0
 public DashboardItem(Loan loan)
 {
     Id = loan.Id;
     Name = loan.Name;
     Date = loan.DueDate;
     Amount = loan.MonthlyPayment;
     IsPastDue = loan.IsPastDue;
     IsShared = false;
     Type = "Loan";
     IsPaid = false;
 }
        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);
                }
            }
        }
 partial void UpdateLoan(Loan instance);
 partial void DeleteLoan(Loan instance);
 partial void InsertLoan(Loan instance);
		private void detach_Loans(Loan entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
		private void attach_Loans(Loan entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}
		private void detach_Loans(Loan entity)
		{
			this.SendPropertyChanging();
			entity.PaymentType = null;
		}
		private void attach_Loans(Loan entity)
		{
			this.SendPropertyChanging();
			entity.PaymentType = this;
		}