public ActionResult Edit(LedgerHead ledgerHead) { UpdateModel(ledgerHead); ModelState.Clear(); TryValidateModel(ledgerHead); if (ModelState.IsValid) { ledgerRepository.SaveLedgerHead(ledgerHead); TempData["message"] = string.Format("{0} saved successfully", ledgerHead.LedgerHeadName); CacheRepository.RefreshLedgerHeads(); return(RedirectToAction("Index")); } SetMetaDataForForm(); return(View(ledgerHead)); }
private void CreateLedgerHead(SampleLedgerHead ledgerHeadStructure) { LedgerRepository.SaveLedgerHead(ledgerHeadStructure.ledgerHead); _ledgerHeadMap.Add(ledgerHeadStructure.ledgerHead.LedgerHeadName.ToLower(), ledgerHeadStructure.ledgerHead.LedgerHeadId); if (ledgerHeadStructure.SampleLedgerHeads != null && ledgerHeadStructure.SampleLedgerHeads.Count > 0) { foreach (var headStructure in ledgerHeadStructure.SampleLedgerHeads) { headStructure.ledgerHead.ParentLedgerTypeId = ledgerHeadStructure.ledgerHead.ParentLedgerTypeId; headStructure.ledgerHead.ParentLedgerHeadId = ledgerHeadStructure.ledgerHead.LedgerHeadId; CreateLedgerHead(headStructure); } } if (ledgerHeadStructure.SampleLedgerAccounts != null && ledgerHeadStructure.SampleLedgerAccounts.Count > 0) { foreach (var ledgerAccount in ledgerHeadStructure.SampleLedgerAccounts) { ledgerAccount.ParentLedgerHeadId = ledgerHeadStructure.ledgerHead.LedgerHeadId; LedgerRepository.SaveLedgerAccount(ledgerAccount); _ledgerAccountMap.Add(ledgerAccount.LedgerAccountName.ToLower(), ledgerAccount.LedgerAccountId); } } }