public ActionResult EditCurrent(CurrentAccViewModel currentAccViewModel) { currentAccViewModel.CurrentAccountType.Name = "Current Account"; // if (!ModelState.IsValid) // { // var GLAccounts = _context.GlAccounts.ToList(); // var viewModel = new CurrentAccViewModel() // { // GlAccounts = GLAccounts, // CurrentAccountType = new AccountType() // }; // return View("Index", viewModel); // } var currentAccountType = _context.AccountTypes.SingleOrDefault(c => c.Name.Equals(currentAccViewModel.CurrentAccountType.Name)); //Mapper.Map(generalLedgerCategoryViewModel, generalLedgerCategory); if (currentAccountType != null) { currentAccountType.Id = currentAccViewModel.CurrentAccountType.Id; currentAccountType.CreditInterestRate = currentAccViewModel.CurrentAccountType.CreditInterestRate; currentAccountType.MinimumBalance = currentAccViewModel.CurrentAccountType.MinimumBalance; currentAccountType.COTIncomeGLAccountId = currentAccViewModel.CurrentAccountType.COTIncomeGLAccountId; currentAccountType.InterestExpenseGLAccountId = currentAccViewModel.CurrentAccountType.InterestExpenseGLAccountId; currentAccountType.COT = currentAccViewModel.CurrentAccountType.COT; } _context.SaveChanges(); return(RedirectToAction("Index", "AccountTypes")); }
public ActionResult CurrentAccConfig(string id) { var GLAccounts = _context.GlAccounts.ToList(); var currentAcc = _context.AccountTypes.SingleOrDefault(c => c.Name.Equals("Current Account")); var viewModel = new CurrentAccViewModel() { GlAccounts = GLAccounts, CurrentAccountType = currentAcc }; return(View("EditCurrentAccConfig", viewModel)); }