예제 #1
0
        public async Task <ResponseEnvelope <MediaTaskModel> > GenerateSaaSUrlForMediaAsync(string filename, int size, long?venueId, long?userId)
        {
            try
            {
                if (size == 0)
                {
                    return(await ResponseEnvelope <MediaTaskModel> .BadRequestAsync(INVALID_DATA));
                }
                Req_MediaTask_Dto dto = new Req_MediaTask_Dto()
                {
                    Filename = filename,
                    PlaceId  = venueId,
                    Size     = size,
                    UserId   = userId
                };
                var response = await this.ClientApi.PostJsonRequestAsync <MediaTask_Dto, Req_MediaTask_Dto>(WebApi.ApiGenerateSaasForMedia, dto);

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

                return(await ResponseEnvelope <MediaTaskModel> .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <MediaTaskModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <MediaTaskModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #2
0
        public async Task <ResponseEnvelope <MediaModel> > PublishMediaAsync(Guid uuId)
        {
            try
            {
                if (uuId == Guid.Empty)
                {
                    return(await ResponseEnvelope <MediaModel> .BadRequestAsync(INVALID_DATA));
                }
                Req_MediaPublish_Dto dto = new Req_MediaPublish_Dto()
                {
                    UuId = uuId
                };
                var response = await this.ClientApi.PostJsonRequestAsync <MediaItem_Dto, Req_MediaPublish_Dto>(WebApi.ApiPublishMedia, dto);

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

                return(await ResponseEnvelope <MediaModel> .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <MediaModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <MediaModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #3
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));
            }
        }
예제 #4
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));
            }
        }
예제 #5
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));
            }
        }
예제 #6
0
        public async Task <ResponseEnvelope <string> > RegisterUserUsingSocialAsync(string accessToken, AuthProvider provider)
        {
            try
            {
                if (string.IsNullOrEmpty(accessToken))
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                if (provider == AuthProvider.Forms)
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                Req_SocialRequest_Dto dto = new Req_SocialRequest_Dto()
                {
                    AccessToken = accessToken, Provider = Enum.GetName(typeof(Enums.AuthProvider), provider).ToLower()
                };
                var response = await this.ClientApi.PostJsonRequestAsync <string, Req_SocialRequest_Dto>(WebApi.ApiSocialRegistration, dto);

                return(response);
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #7
0
        public async Task <ResponseEnvelope <FriendDetailsModel> > GetFriendProfileAsync(long id)
        {
            try
            {
                if (id == 0)
                {
                    return(await ResponseEnvelope <FriendDetailsModel> .BadRequestAsync(INVALID_DATA));
                }
                var response = await this.ClientApi.GetRequestAsync <FriendProfile_Dto>(string.Format("{0}{1}", WebApi.ApiFriendProfile, id));

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

                return(await ResponseEnvelope <FriendDetailsModel> .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <FriendDetailsModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <FriendDetailsModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #8
0
        public async Task <ResponseEnvelope <string> > LogoutAsync()
        {
            try
            {
                var currentUser = this.userRepository.GetUser();

                if (currentUser == null)
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                var response = await this.ClientApi.PostJsonRequestAsync <string, object>(WebApi.ApiLogout, null);

                if (response.Ack == AckCode.SUCCESS)
                {
                    //update user data in local db
                    userRepository.ClearUser();
                    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));
            }
        }
예제 #9
0
        public async Task <ResponseEnvelope <UserModel> > SocialLoginAsync(string accessToken, AuthProvider provider)
        {
            try
            {
                if (string.IsNullOrEmpty(accessToken))
                {
                    return(await ResponseEnvelope <UserModel> .BadRequestAsync(INVALID_DATA));
                }
                if (provider == AuthProvider.Forms)
                {
                    return(await ResponseEnvelope <UserModel> .BadRequestAsync(INVALID_DATA));
                }
                Req_SocialRequest_Dto dto = new Req_SocialRequest_Dto()
                {
                    AccessToken = accessToken, Provider = Enum.GetName(typeof(Enums.AuthProvider), provider).ToLower()
                };
                var response = await this.ClientApi.PostJsonRequestAsync <UserProfile_Dto, Req_SocialRequest_Dto>(WebApi.ApiSocialLogin, dto);

                if (response.Ack == AckCode.SUCCESS)
                {
                    //update user data in local db
                    userRepository.ClearUser();
                    UserEntity dbUser = response.Data.ToDbEntity();
                    if (dbUser != null)
                    {
                        userRepository.SaveUser(dbUser);
                        this.RefreshProxyData();
                    }
                    return(await ResponseEnvelope <UserModel> .SuccessAsync(response.Data.ToModel()));
                }

                return(await ResponseEnvelope <UserModel> .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <UserModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <UserModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #10
0
        public async Task <ResponseEnvelope <UserModel> > LoginAsync(string username, string password)
        {
            try
            {
                if (string.IsNullOrEmpty(username))
                {
                    return(await ResponseEnvelope <UserModel> .BadRequestAsync(INVALID_DATA));
                }
                if (string.IsNullOrEmpty(password))
                {
                    return(await ResponseEnvelope <UserModel> .BadRequestAsync(INVALID_DATA));
                }
                Req_FormLogin_Dto dto = new Req_FormLogin_Dto()
                {
                    Password = password, Username = username
                };
                var response = await this.ClientApi.PostJsonRequestAsync <UserProfile_Dto, Req_FormLogin_Dto>(WebApi.ApiFormsLogin, dto);

                if (response.Ack == AckCode.SUCCESS)
                {
                    //update user data in local db
                    userRepository.ClearUser();
                    UserEntity dbUser = response.Data.ToDbEntity();
                    if (dbUser != null)
                    {
                        userRepository.SaveUser(dbUser);
                        this.RefreshProxyData();
                    }
                    return(await ResponseEnvelope <UserModel> .SuccessAsync(response.Data.ToModel()));
                }

                return(await ResponseEnvelope <UserModel> .ErrorAsync(response.Message));
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <UserModel> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <UserModel> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #11
0
        public async Task <ResponseEnvelope <string> > RegisterUserUsingFormsAsync(UserModel data)
        {
            try
            {
                if (data == null)
                {
                    return(await ResponseEnvelope <string> .BadRequestAsync(INVALID_DATA));
                }
                var response = await this.ClientApi.PostJsonRequestAsync <string, Req_FormRegister_Dto>(WebApi.ApiFormsRegistration, data.ToDto());

                return(response);
            }
            catch (NoInternetConnectionException)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(NO_INTERNET_CONNECTION));
            }
            catch (Exception ex)
            {
                return(await ResponseEnvelope <string> .ErrorAsync(INTERNAL_ERROR, ex));
            }
        }
예제 #12
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));
            }
        }
예제 #13
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));
            }
        }
예제 #14
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));
            }
        }
예제 #15
0
        public async Task <ResponseEnvelope <UserModel> > UpdateUserProfileAsync(UserModel data)
        {
            try
            {
                if (data == null)
                {
                    return(await ResponseEnvelope <UserModel> .BadRequestAsync(INVALID_DATA));
                }
                var response = await this.ClientApi.PostJsonRequestAsync <UserProfile_Dto, UserProfile_Dto>(WebApi.ApiUpdateProfile, data.ToProfileDto());

                if (response.Ack == AckCode.SUCCESS)
                {
                    this.currentUser = userRepository.GetUser();
                    if (this.CurrentUser == null)
                    {
                        return(await ResponseEnvelope <UserModel> .ErrorAsync(INTERNAL_ERROR));
                    }
                    var newUser = response.Data.UpdateDbEntity(currentUser);
                    //update user data in local db
                    userRepository.ClearUser();
                    userRepository.SaveUser(newUser);
                    this.RefreshProxyData();
                    return(await ResponseEnvelope <UserModel> .SuccessAsync(response.Data.ToModel()));
                }

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