public IActionResult GetAccountByID(int id) { var account = _accountAppService.GetID(id); var ParentAccount = new Account(); var accountNature = new AccountNature(); if (account.ParentAccount != null) { ParentAccount = _accountAppService.GetID((int)account.ParentAccount); } if (account.AccountNature != null) { accountNature = _accNatureAppService.GetID((int)account.AccountNature); } AccountViewModel model = new AccountViewModel(); model.ID = account.ID; model.AccountDesc = account.AccountDesc; model.AccountName = account.AccountName; model.AccountNatureID = account.AccountNature; model.AccountNatureName = accountNature.AccountNatureName; model.AccountSerial = account.AccountSerial; model.Active = account.Active; model.GroupOrder = account.GroupOrder; model.IsMain = account.IsMain; model.ParentAccountID = account.ParentAccount; model.ParentAccountName = ParentAccount.AccountName; return(Json(model)); }
public IActionResult Create([Bind("AccountNatureName,ID")] AccountNature accountNature) { if (ModelState.IsValid) { _accNatureAppService.Insert(accountNature); return(RedirectToAction(nameof(Index))); } return(View(accountNature)); }
public JsonResult SaveAccountNature(AccountNature item) { var newAccount = _accNatureAppService.GetID(item.ID); if (newAccount == null) { _accNatureAppService.Insert(item); } else { AccountNature viewPar = _ctx.AccountNatures.FirstOrDefault(F => F.ID == item.ID); viewPar.AccountNatureName = item.AccountNatureName; viewPar.ID = item.ID; _ctx.SaveChanges(); } return(Json(item)); }