public ActionResult ProfitPayment(int id) { var userProfitManager = new UserProfitManager(); ViewBag.UserId = id; ViewBag.PreviousPayments = db.UserProfitPayments.Where(u => u.UserId == id).ToList(); ViewBag.UnpayedProfit = userProfitManager.CalculateUserProfit(id); return(View()); }
public ActionResult ProfitPayment(UserProfitPayment payment) { try { payment.Date = DateTime.Now; db.UserProfitPayments.Add(payment); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { var userProfitManager = new UserProfitManager(); ViewBag.UserId = payment.UserId; ViewBag.PreviousPayments = db.UserProfitPayments.Where(u => u.UserId == payment.UserId).ToList(); ViewBag.UnpayedProfit = userProfitManager.CalculateUserProfit(payment.UserId); return(View()); } }