public IActionResult Load(Int64?groupID, Int64?langId)
        {
            GetGroups operation = new GetGroups();

            operation.ID = groupID;

            if (langId.HasValue)
            {
                operation.LangID = langId;
            }
            else
            {
                operation.LangID = 1;
            }

            var result = operation.QueryAsync().Result;

            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok((List <Group>)result));
            }
        }
        public IActionResult Load(Int64?ID, Int64?userID, Int64?langId)
        {
            GetUserGroups operation = new GetUserGroups();


            if (langId.HasValue)
            {
                operation.LangID = langId;
            }
            else
            {
                operation.LangID = 1;
            }
            if (!userID.HasValue)
            {
                operation.ID = ID;
                var results = operation.QueryAsync().Result;
                return(Ok((List <UserGroup>)results));
            }
            operation.UserID = userID;
            var       result     = operation.QueryAsync().Result;
            var       userGroups = (List <UserGroup>)result;
            GetGroups groups     = new GetGroups();

            groups.LangID = 1;
            if (langId.HasValue)
            {
                groups.LangID = langId;
            }
            else
            {
                groups.LangID = 1;
            }
            var          Groups = (List <Group>)groups.QueryAsync().Result;
            List <Group> returnedRelatedGroups   = new List <Group>();
            List <Group> returnedUnRelatedGroups = new List <Group>();

            if (userGroups.Count > 0)
            {
                foreach (var group in Groups)
                {
                    foreach (var item in userGroups)
                    {
                        if (group.ID == item.RefrenceID)
                        {
                            bool alreadyExist             = returnedRelatedGroups.Contains(group);
                            bool alreadyExistInSecondList = returnedUnRelatedGroups.Contains(group);
                            if (!alreadyExist && !alreadyExistInSecondList)
                            {
                                group.UserRelationID = item.ID;
                                returnedRelatedGroups.Add(group);
                            }
                            else
                            {
                                group.UserRelationID = item.ID;
                                returnedRelatedGroups.Add(group);
                                returnedUnRelatedGroups.Remove(group);
                            }
                        }
                        else
                        {
                            bool alreadyExist            = returnedUnRelatedGroups.Contains(group);
                            bool alreadyExistInFirstList = returnedRelatedGroups.Contains(group);
                            if (!alreadyExist && !alreadyExistInFirstList)
                            {
                                group.UserRelationID = item.ID;
                                returnedUnRelatedGroups.Add(group);
                            }
                        }
                    }
                }
            }
            else
            {
                returnedUnRelatedGroups = Groups;
            }


            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok(new { RelatedGroups = returnedRelatedGroups, UnRelatedGroups = returnedUnRelatedGroups }));
            }
        }