protected IncomeUserPayment GetIncomeUserPayment(int?id) { IncomeUserPayment incomeUserPayment = db.IncomeUserPayments.Find(id); if (incomeUserPayment == null || incomeUserPayment.User.Id != user.Id) { return(null); } incomeUserPayment.IncomeUser = GetIncomeUser(incomeUserPayment.IncomeUser.ID).Populate(user); return(incomeUserPayment); }
public ActionResult EditPayment(int?id) { ViewBag.Action = "Edit Payment"; IncomeUserPayment incomeUserPayment = GetIncomeUserPayment(id); if (incomeUserPayment == null) { return(HttpNotFound()); } return(View("Payment", incomeUserPayment)); }
public ActionResult DeletePayment(int?id) { IncomeUserPayment incomeUserPayment = GetIncomeUserPayment(id); if (incomeUserPayment == null) { return(HttpNotFound()); } IncomeUser incomeUser = incomeUserPayment.IncomeUser; db.IncomeUserPayments.Remove(incomeUserPayment); db.SaveChanges(); return(RedirectToAction("Details", new { id = incomeUser.ID })); }
public ActionResult AddPayment(int?id, [Bind(Include = "Amount,Date,IncomeUser.ID")] IncomeUserPayment incomeUserPayment) { ViewBag.Action = "Add Payment"; incomeUserPayment.IncomeUser = GetIncomeUser(id); if (incomeUserPayment == null) { return(HttpNotFound()); } if (ModelState.IsValid) { incomeUserPayment.User = db.Users.Find(user.Id); db.IncomeUserPayments.Add(incomeUserPayment); db.SaveChanges(); return(RedirectToAction("Details", new { id = incomeUserPayment.IncomeUser.ID })); } return(View("Payment", incomeUserPayment)); }
public ActionResult AddPayment(int?id) { ViewBag.Action = "Add Payment"; IncomeUser incomeUser = GetIncomeUser(id); if (incomeUser == null) { return(HttpNotFound()); } NotPaidIncomeUserPayemnt np = incomeUser.NotPaidIncomeUserPayments.OrderBy(x => x.Date).FirstOrDefault(); IncomeUserPayment payment = new IncomeUserPayment() { Date = np.Date, Amount = np.Amount, IncomeUser = incomeUser }; return(View("Payment", payment)); }
public ActionResult EditPayment(int id, [Bind(Include = "Amount,Date")] IncomeUserPayment incomeUserPayment) { ViewBag.Action = "Edit Payment"; IncomeUserPayment ip = GetIncomeUserPayment(id); if (ip == null) { return(HttpNotFound()); } if (ModelState.IsValid) { ip.Amount = incomeUserPayment.Amount; ip.Date = incomeUserPayment.Date; db.Entry(ip).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = ip.IncomeUser.ID })); } return(View("Payment", incomeUserPayment)); }