public JsonResult GetGroupList(int accountId) { string functionName = System.Reflection.MethodBase.GetCurrentMethod().Name; try { //Check value enter id account if (accountId == 0) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.emailAndPasswordWrong)); return(Json(MessageResult.GetMessage(MessageType.EMAIL_AND_PASSWORD_WRONG))); } //get group list by owner Id List <GroupOwnerEntity> groupEntities = _groupRepository.GetGroupListByOwnerId(accountId); List <GroupMemberEntity> groupMembers = _groupMemberRepository.GetGroupMemberByAccountId(accountId); if (groupEntities == null) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.groupNotFound)); return(Json(MessageResult.GetMessage(MessageType.GROUP_NOT_FOUND))); } // Create new list result to get data List <GroupListResult> groupListResult = new List <GroupListResult>(); foreach (var groupOwner in groupEntities) { GroupEntity group = _groupRepository.GetGroupById(groupOwner.GroupId); GroupListResult groupList = new GroupListResult(); groupList.groupId = groupOwner.GroupId.ToString("0000"); groupList.groupOwnerId = groupOwner.GroupOwnerId; groupList.ownerGroupId = groupOwner.AccountId; groupList.groupName = group.Name; groupList.description = group.Description; groupListResult.Add(groupList); } foreach (var groupMember in groupMembers) { GroupEntity group = _groupRepository.GetGroupById(groupMember.GroupId); GroupListResult groupList = new GroupListResult(); groupList.groupId = groupMember.GroupId.ToString("0000"); groupList.groupOwnerId = groupMember.GroupMemberId; groupList.ownerGroupId = groupMember.AccountId; groupList.groupName = group.Name; groupList.description = group.Description; groupListResult.Add(groupList); } return(Json(groupListResult.OrderByDescending(a => a.groupId))); } catch (Exception ex) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(ex.Message)); return(Json(MessageResult.ShowServerError(ex.Message))); } }