public SavingsAccountConfigViewModel(SavingsAccountConfig config) { if (config == null) { Id = 0; } else { Id = config.Id; CInterestRate = config.CInterestRate; InterestExpenseGlId = config.InterestExpenseGlId; InterestPayableGlId = (int)config.InterestPayableGlId; MinBalance = config.MinBalance; Status = config.Status; InterestExpenseGl = config.InterestExpenseGl; } }
public ActionResult SaveSavingsConfig(SavingsAccountConfig config) { var glAccount = new GlAccount(); var configInDb = _context.GetSavingsConfig(); var glAccountInDb = _glAccountContext.Get(config.InterestExpenseGlId); if (config.Id == 0) //setup new configuration { glAccountInDb.IsAssigned = true; // Update the gl account to is assigned _glAccountContext.Update(glAccount); config.Status = true; _context.SaveSavings(config); TempData["Success"] = "Configurations Added Successfully"; return(RedirectToAction("SavingsAccount")); } if (config.Id != 0) //update current savings configuration { configInDb.CInterestRate = config.CInterestRate; configInDb.MinBalance = config.MinBalance; configInDb.InterestPayableGlId = config.InterestPayableGlId; if (config.InterestExpenseGlId == 0) //check if gl account is the same { configInDb.InterestExpenseGlId = configInDb.InterestExpenseGlId; } else { var newGlAccountInDb = _glAccountContext.Get(configInDb.InterestExpenseGlId); // free up the old gl account that was assigned newGlAccountInDb.IsAssigned = false; _glAccountContext.Update(glAccount); configInDb.InterestExpenseGlId = config.InterestExpenseGlId; glAccountInDb.IsAssigned = true; // Update the new gl account to is assigned _glAccountContext.Update(glAccount); } TempData["Success"] = "Configurations Updated Successfully"; _context.UpdateSavings(config); } return(RedirectToAction("SavingsAccount")); }
public void UpdateSavings(SavingsAccountConfig savingsConfig) { _savingsAccContext.Save(savingsConfig); }
public void SaveSavings(SavingsAccountConfig config) { _savingsAccContext.Add(config); _savingsAccContext.Save(config); }