public ActionResult AddDebit(Debit debit) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("login", "Home")); } var UserRepo = new UserRepository(Properties.Settings.Default._connectionString); var budgetRepo = new BudgetRepository(Properties.Settings.Default._connectionString); debit.UserId = UserRepo.GetUserByEmail(User.Identity.Name).Id; List <Debit> Debits = budgetRepo.AddDebit(debit); // = budgetRepo.GetDebitsByMonthId(debit.UserId, debit.MonthId); //return Json(debit); return(Json(new { debits = Debits.Select(D => new { id = D.Id, amount = D.Amount.ToString("C"), date = D.Date, category = D.Category.CategoryName, detail = D.Details }), debitTotal = Debits.Sum(D => D.Amount).ToString("C") })); }