public CoaManager() { _aGlAccount = new GenericRepositoryAccount <A_GlAccount>(); _coaVM = new A_GlAccountViewModel(); _aModel = new ResponseModel(); _db = new Entities.Entities(); }
public List <A_GlAccountViewModel> GetCartOfAccount() { List <A_GlAccount> SuperParrentAccount = _aGlAccount.SelectAll().Where(x => x.ParentId == null).Select(a => new A_GlAccount { A_GlAccountId = a.A_GlAccountId, ParentId = a.ParentId, Code = a.Code, Name = a.Name + "(" + a.Code + ")", TransactionAllowed = a.TransactionAllowed, IsActive = a.IsActive }).ToList(); foreach (var aGlAccount in SuperParrentAccount) { _coaVM = new A_GlAccountViewModel(); _coaVM.Id = aGlAccount.A_GlAccountId; _coaVM.Code = aGlAccount.Code; _coaVM.Parent = Convert.ToInt32(aGlAccount.ParentId); _coaVM.AccountName = aGlAccount.Name; _coaVM.transactionAllowed = aGlAccount.TransactionAllowed; a_GlList.Add(_coaVM); GetChild(aGlAccount.A_GlAccountId); } return(a_GlList); }
private void GetChild(int parrentId) { var ChildAsParrentAccount = _aGlAccount.SelectAll().Where(x => x.ParentId == parrentId) .Select(a => new A_GlAccount { A_GlAccountId = a.A_GlAccountId, ParentId = a.ParentId, Name = a.Name + "(" + a.Code.ToString() + ")", TransactionAllowed = a.TransactionAllowed, IsActive = a.IsActive }).ToList(); foreach (var coa in ChildAsParrentAccount) { _coaVM = new A_GlAccountViewModel(); _coaVM.Id = coa.A_GlAccountId; _coaVM.Code = coa.Code; _coaVM.Parent = Convert.ToInt32(coa.ParentId); _coaVM.AccountName = coa.Name; _coaVM.transactionAllowed = coa.TransactionAllowed; if (_coaVM.transactionAllowed) { _coaVM.Children = true; } else { _coaVM.Children = false; } a_GlList.Add(_coaVM); GetChild(coa.A_GlAccountId); } }