Example #1
0
        public async Task <ResponseEnvelope <FriendModel> > AcceptFriendRequestAsync(long friendRequestId)
        {
            try
            {
                if (friendRequestId == 0)
                {
                    return(await ResponseEnvelope <FriendModel> .BadRequestAsync(INVALID_DATA));
                }
                SimpleDataWrapper_Dto <long> dto = new SimpleDataWrapper_Dto <long>()
                {
                    Data = friendRequestId
                };
                var response = await this.ClientApi.PostJsonRequestAsync <Friend_Dto, SimpleDataWrapper_Dto <long> >(WebApi.ApiAcceptFriendRequest, dto);

                if (response.Ack == AckCode.SUCCESS)
                {
                    return(await ResponseEnvelope <FriendModel> .SuccessAsync(response.Data.ToModel()));
                }

                return(await ResponseEnvelope <FriendModel> .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <FriendModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <FriendModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
Example #2
0
        public async Task <ResponseEnvelope <FriendRequestModel> > SendFriendRequestAsync(long userId)
        {
            try
            {
                if (userId == 0)
                {
                    return(await ResponseEnvelope <FriendRequestModel> .BadRequestAsync(INVALID_DATA));
                }
                SimpleDataWrapper_Dto <long> dto = new SimpleDataWrapper_Dto <long>()
                {
                    Data = userId
                };
                var response = await this.ClientApi.PostJsonRequestAsync <FriendRequest_Dto, SimpleDataWrapper_Dto <long> >(WebApi.ApiSendFriendRequest, dto);

                return(await ResponseEnvelope <FriendRequestModel> .SuccessAsync(response.Data.ToFriendRequestModel()));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <FriendRequestModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <FriendRequestModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
Example #3
0
        public async Task <ResponseEnvelope <string> > InviteUserToUseAppBySMSAsync(string phoneNumber)
        {
            try
            {
                if (string.IsNullOrEmpty(phoneNumber))
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                SimpleDataWrapper_Dto <string> dto = new SimpleDataWrapper_Dto <string>()
                {
                    Data = phoneNumber
                };
                var response = await this.ClientApi.PostJsonRequestAsync <string, SimpleDataWrapper_Dto <string> >(WebApi.ApiInvitePeopleToUseTheAppBySMS, dto);

                return(response);
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
Example #4
0
        public async Task <ResponseEnvelope <List <FriendModel> > > CheckPeopleUsingTheAppByEmailAsync(List <string> emails)
        {
            try
            {
                if (emails == null)
                {
                    return(await ResponseEnvelope <List <FriendModel> > .BadRequestAsync(INVALID_DATA));
                }
                if (emails.Count == 0)
                {
                    return(await ResponseEnvelope <List <FriendModel> > .BadRequestAsync(INVALID_DATA));
                }
                SimpleDataWrapper_Dto <List <string> > dto = new SimpleDataWrapper_Dto <List <string> >()
                {
                    Data = emails
                };
                var response = await this.ClientApi.PostJsonRequestAsync <List <InAppUser_Dto>, SimpleDataWrapper_Dto <List <string> > >(WebApi.ApiCheckPeopleUsingAppByEmail, dto);

                if (response.Ack == AckCode.SUCCESS)
                {
                    if (response.Data == null)
                    {
                        response.Data = new List <InAppUser_Dto>();
                    }
                    return(await ResponseEnvelope <List <FriendModel> > .SuccessAsync(response.Data.Select(s => s.ToModel()).ToList()));
                }

                return(await ResponseEnvelope <List <FriendModel> > .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <List <FriendModel> > .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <List <FriendModel> > .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
Example #5
0
        public async Task <ResponseEnvelope <string> > SendPhoneConfirmationCodeAsync(string phoneNumber)
        {
            try
            {
                if (string.IsNullOrEmpty(phoneNumber))
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                SimpleDataWrapper_Dto <string> dto = new SimpleDataWrapper_Dto <string>()
                {
                    Data = phoneNumber
                };
                var response = await this.ClientApi.PostJsonRequestAsync <string, SimpleDataWrapper_Dto <string> >(WebApi.ApiSendPhoneConfirmationCode, dto);

                if (response.Ack == AckCode.SUCCESS)
                {
                    //update user data in local db
                    var currentUser = userRepository.GetUser();
                    if (currentUser != null)
                    {
                        currentUser.Phone = phoneNumber;
                        userRepository.SaveUser(currentUser);
                        this.RefreshProxyData();
                    }
                }

                return(response);
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
Example #6
0
        public async Task <ResponseEnvelope <string> > ConfirmPhoneNumberAsync(string code)
        {
            try
            {
                if (string.IsNullOrEmpty(code))
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                SimpleDataWrapper_Dto <string> dto = new SimpleDataWrapper_Dto <string>()
                {
                    Data = code
                };
                var response = await this.ClientApi.PostJsonRequestAsync <string, SimpleDataWrapper_Dto <string> >(WebApi.ApiConfirmPhoneNumber, dto);

                if (response.Ack == AckCode.SUCCESS)
                {
                    //update user data in local db
                    this.currentUser = userRepository.GetUser();
                    if (this.currentUser != null)
                    {
                        this.currentUser.PhoneNumberConfirmed = true;
                        userRepository.SaveUser(this.currentUser);
                    }
                }

                return(response);
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }