public ActionResult EditSavings(SavingsViewModel savingsViewModel) { savingsViewModel.SavingsAccountType.Name = "Savings Account"; // if (!ModelState.IsValid) // { // var GLAccounts = _context.GlAccounts.ToList(); // var viewModel = new SavingsViewModel() // { // GlAccounts = GLAccounts, // SavingsAccountType = new AccountType() // }; // return View("Index", viewModel); // } var savingsAccountType = _context.AccountTypes.SingleOrDefault(c => c.Name.Equals(savingsViewModel.SavingsAccountType.Name)); //Mapper.Map(generalLedgerCategoryViewModel, generalLedgerCategory); if (savingsAccountType != null) { savingsAccountType.Id = savingsViewModel.SavingsAccountType.Id; savingsAccountType.CreditInterestRate = savingsViewModel.SavingsAccountType.CreditInterestRate; savingsAccountType.MinimumBalance = savingsViewModel.SavingsAccountType.MinimumBalance; savingsAccountType.InterestExpenseGLAccountId = savingsViewModel.SavingsAccountType.InterestExpenseGLAccountId; } _context.SaveChanges(); return(RedirectToAction("Index", "AccountTypes")); }
public ActionResult Delete(SavingsViewModel model) { try { _savingLogic.DeleteSaving(model.SavingId); return(RedirectToAction(nameof(Index), "Account")); } catch { return(RedirectToAction("Index", "Account")); } }
public SavingsViewModel CreateNeededModelForSavingIndex() { var savings = _itemFetcherService.GetSavings(10); SavingsViewModel model = new SavingsViewModel() { Savings = savings, BudgetedForSavings = _user.BudgetedForSavings }; return(model); }
public ActionResult SavingsAccConfig(string id) { var GLAccounts = _context.GlAccounts.ToList(); var savingsAcc = _context.AccountTypes.SingleOrDefault(c => c.Name.Equals("Savings Account")); var viewModel = new SavingsViewModel() { GlAccounts = GLAccounts, SavingsAccountType = savingsAcc }; return(View("EditSavingsAccConfig", viewModel)); }
public ActionResult Edit(SavingsViewModel model) { try { _savingLogic.UpdateSaving(model); return(RedirectToAction(nameof(Details), "Savings", new { id = model.SavingId })); } catch { return(RedirectToAction(nameof(Details), "Savings", new { id = model.SavingId })); } }
public ActionResult Details(int id) { var reservationsContext = _savingLogic.GetSavingReservations(id); ViewBag.Reservations = reservationsContext.Select(reserve => new ReservationViewModel(reserve)); var savingContext = _savingLogic.GetSavingById(id); var model = new SavingsViewModel(savingContext.UserId, id, savingContext.SavingName, savingContext.SavingCurrentAmount, savingContext.SavingsGoalAmount, savingContext.State, savingContext.IconId, savingContext.GoalDate); ViewBag.FileProvider = _fileProvider.GetDirectoryContents("wwwroot/Icons/Savings").ToList().Select(icon => icon.Name).ToList(); ViewBag.Accounts = _accountLogic.GetUserAccounts(HttpContext.Session.GetString("UserSession")); ViewBag.Savings = _savingLogic.GetOngoingUserSavings((int)HttpContext.Session.GetInt32("UserId")); return(View("~/Views/Savings/SavingDetails.cshtml", model)); }
public async Task <IActionResult> Create(SavingsViewModel model) { if (ModelState.IsValid) { var saving = new Saving { Amount = model.Amount, Type = _context.SavingType.SingleOrDefault(u => u.SavingTypeId == model.SavingTypeId) }; _context.Add(saving); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }