public ActionResult Create() { Account account = new Account(); ViewBag.PossibleAccountCategories = accountcategoryRepository.All; ViewBag.PossibleParentAccounts = accountRepository.All; return View(account); }
public ActionResult Create(Account account) { if (ModelState.IsValid) { accountRepository.InsertOrUpdate(account); accountRepository.Save(); return RedirectToAction("Index"); } else { ViewBag.PossibleAccountCategories = accountcategoryRepository.All; ViewBag.PossibleParentAccounts = accountRepository.All; return View(account); } }
public void InsertOrUpdate(Account account) { if (account.AccountID == default(int)) { // New entity context.Account.Add(account); } else { // Existing entity context.Entry(account).State = EntityState.Modified; } }
public ViewResult Search(Account searchAccount) { if(searchAccount!=null) { } return View("Index",accountRepository.AllIncluding(account => account.AccountCategory, account => account.ParentAccount)); }