Exemple #1
0
        public async Task <UserGroupRelationshipStatus> GetGroupRelationshipStatus(string authenticationToken, string groupId, string userId)
        {
            try
            {
                UserGroupService            groupService            = new UserGroupService();
                UserGroupRelationshipStatus groupRelationshipStatus = new UserGroupRelationshipStatus();

                var response = await groupService.GetGroupRelationshipStatus(authenticationToken, groupId, userId);

                if (response.IsSuccessStatusCode)
                {
                    string result = await response.Content.ReadAsStringAsync();

                    if (!string.IsNullOrEmpty(result))
                    {
                        Enum.TryParse(result, out groupRelationshipStatus);

                        return(groupRelationshipStatus);
                    }
                    else
                    {
                        return(UserGroupRelationshipStatus.NotMember);
                    }
                }
                else
                {
                    if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                    {
                        throw new Exception("Unauthorized");
                    }
                    else
                    {
                        throw new Exception(response.StatusCode.ToString() + " - " + response.ReasonPhrase);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }