Exemplo n.º 1
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataModelDeletePost result = new DataModelDeletePost();

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result.Status = EPostHeaderResponseStatus.Success;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseDeletePost(responseModel.Body);
                    result.Status = EPostHeaderResponseStatus.Unauthorized;
                });
            }
            else
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseDeletePost(responseModel.Body);
                    result.Status = EPostHeaderResponseStatus.Error;
                });
            }

            if (result != null)
            {
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 2
0
        public void SetMessage(IModelResponse responseModel)
        {
            if (string.IsNullOrEmpty(responseModel.Body))
            {
                return;
            }

            WidgetResponse widgetResponse = null;

            try
            {
                widgetResponse = _parseResponseWidget(responseModel.Body);
            }
            catch (ParseException)
            {
                OnRecieveModel?.Invoke(new DataModelListQc {
                    Status = EQcResponseStatus.Error
                });
                return;
            }

            if (widgetResponse.Module == ESocketModuleAnswer.rates)
            {
                ParseRates(responseModel.Status, widgetResponse.Args);
            }
        }
Exemplo n.º 3
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataModelPostLike result = null;

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseLikePost(responseModel.Body);
                    result.Status = EPostSocialResponseStatus.Success;
                    DataService.RepositoryController.RepositoryPost.PostLike = result;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseLikePost(responseModel.Body);
                    result.Status = EPostSocialResponseStatus.Unauthorized;
                });
            }
            else
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseLikePost(responseModel.Body);
                    result.Status = EPostSocialResponseStatus.Error;
                });
            }

            if (result != null)
            {
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 4
0
 public void SetMessage(IModelResponse responseModel)
 {
     if (responseModel.Status.Equals(HttpStatusCode.OK))
     {
         _repoController.Init();
         (ContactCreator as ISocketConnector)?.DisconnectSockets();
         OnRecieveModel?.Invoke(new Response {
             ControllerStatus = EControllerStatus.Ok
         });
     }
     else if (responseModel.Status.Equals(HttpStatusCode.NotFound))
     {
         OnRecieveModel?.Invoke(new Response {
             ControllerStatus = EControllerStatus.Error
         });
     }
     else if (responseModel.Status.Equals(HttpStatusCode.ExpectationFailed))
     {
         OnRecieveModel?.Invoke(new Response {
             ControllerStatus = EControllerStatus.NoConnection
         });
     }
     else
     {
         OnRecieveModel?.Invoke(new Response {
             ControllerStatus = EControllerStatus.Error
         });
     }
     _currentRecieveStatus = EControllerStatus.None;
 }
Exemplo n.º 5
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataModelUserInfo result = null;

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result                            = _parseResponseUserInfo(responseModel.Body);
                    result.Status                     = EUserSettingsResponseState.Success;
                    result.ControllerStatus           = EControllerStatus.Ok;
                    _repository.EditContactUserInfo   = result;
                    _repository.EditProfileUserInfo   = result;
                    _repositoryUserAuth.AuthData.Name = result.IsNickName ? result.Nickname : result.FirstName + " " + result.LastName;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.RequestTimeout))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseUserInfo(responseModel.Body);
                    result.Status           = EUserSettingsResponseState.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.ExpectationFailed))
            {
                OnRecieveModel?.Invoke(new DataModelMock
                {
                    ControllerStatus = EControllerStatus.NoConnection
                });
                _currentRecieveStatus = EControllerStatus.None;
                return;
            }
            else if (responseModel.Status.Equals(HttpStatusCode.NotFound))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseUserInfo(responseModel.Body);
                    result.Status           = EUserSettingsResponseState.UserNotFound;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseUserInfo(responseModel.Body);
                    result.Status           = EUserSettingsResponseState.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }

            if (result != null)
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 6
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataModelUserInfo result = null;

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result                          = _parseResponseEditProfile(responseModel.Body);
                    result.Status                   = EUserSettingsResponseState.Success;
                    result.ControllerStatus         = EControllerStatus.Ok;
                    _repository.EditProfileUserInfo = result;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseEditProfile(responseModel.Body);
                    result.Status           = EUserSettingsResponseState.Unauthorized;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.RequestTimeout))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseEditProfile(responseModel.Body);
                    result.Status           = EUserSettingsResponseState.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.BadGateway))
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(new DataModelMock
                {
                    ControllerStatus = EControllerStatus.NoConnection
                });
                return;
            }
            else
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseEditProfile(responseModel.Body);
                    result.Status           = EUserSettingsResponseState.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }

            if (result != null)
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 7
0
        private void HandleResponse(IModelResponse response)
        {
            if (response == null)
            {
                OnMessage?.Invoke(new Response {
                    Status = HttpStatusCode.Gone
                });
                return;
            }

            OnMessage?.Invoke(response);
        }
Exemplo n.º 8
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataRecoveryPasswordResponse result = null;

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseForgotPass(responseModel.Body);
                    result.Status           = EForgotPassStatus.RecoverySuccess;
                    result.ControllerStatus = EControllerStatus.Ok;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseForgotPass(responseModel.Body);
                    result.Status           = EForgotPassStatus.UserNotFound;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }

            else if (responseModel.Status.Equals(HttpStatusCode.BadGateway))
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(new DataModelMock
                {
                    ControllerStatus = EControllerStatus.NoConnection
                });
                return;
            }
            else
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseForgotPass(responseModel.Body);
                    result.Status           = EForgotPassStatus.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }

            if (result != null)
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 9
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataModelReg result = null;

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseReg(responseModel.Body);
                    result.Status           = ERegResponseStatus.Success;
                    result.ControllerStatus = EControllerStatus.Ok;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.RequestTimeout))
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseReg(responseModel.Body);
                    result.Status = ERegResponseStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.BadGateway))
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(new DataModelMock
                {
                    ControllerStatus = EControllerStatus.NoConnection
                });
                return;
            }
            else
            {
                ParseCheck(() =>
                {
                    result        = _parseResponseReg(responseModel.Body);
                    result.Status = ERegResponseStatus.Error;
                });
            }
            if (result != null)
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 10
0
        public void SetMessage(IModelResponse responseModel)
        {
            var result = new DataModelListPosts();

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                try
                {
                    ProccessResponse(responseModel.Body);
                    result.PostIds = _repositoryPost.GetPostIds();
                }
                catch (ParseException)
                {
                    result.Status           = EPostResponseStatus.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                    OnRecieveModel?.Invoke(result);
                }
            }
            else if (responseModel.Status.Equals(HttpStatusCode.BadGateway))
            {
                result.ControllerStatus = EControllerStatus.NoConnection;
                OnRecieveModel?.Invoke(result);
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                result.Status           = EPostResponseStatus.Unauthorized;
                result.ControllerStatus = EControllerStatus.Error;
                OnRecieveModel?.Invoke(result);
            }
            else
            {
                result.Status           = EPostResponseStatus.Error;
                result.ControllerStatus = EControllerStatus.Error;
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 11
0
        public void SetMessage(IModelResponse responseModel)
        {
            DataModelAuth result = null;

            if (responseModel.Status.Equals(HttpStatusCode.OK))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseAuth(responseModel.Body);
                    result.Status           = EAuthResponseStatus.Success;
                    result.ControllerStatus = EControllerStatus.Ok;
                    DataService.RepositoryController.RepositoryRA.ModelAuth = result;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseAuth(responseModel.Body);
                    result.Status           = EAuthResponseStatus.Unauthorized;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.RequestTimeout))
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseAuth(responseModel.Body);
                    result.Status           = EAuthResponseStatus.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.BadGateway))
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(new DataModelMock
                {
                    ControllerStatus = EControllerStatus.NoConnection
                });
                return;
            }
            else if (responseModel.Status.Equals((HttpStatusCode)422))
            {
                result                  = _parseResponseAuth(responseModel.Body);
                result.Status           = EAuthResponseStatus.UnprocessableEntity;
                result.ControllerStatus = EControllerStatus.Error;
            }
            else
            {
                ParseCheck(() =>
                {
                    result                  = _parseResponseAuth(responseModel.Body);
                    result.Status           = EAuthResponseStatus.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }

            if (result != null)
            {
                _currentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(result);
            }
        }
Exemplo n.º 12
0
 public void SetMessage(IModelResponse responseModel)
 {
 }
Exemplo n.º 13
0
        public virtual void SetMessage(IModelResponse responseModel)
        {
            DataModelCreatePost result = new DataModelCreatePost();

            if (responseModel.Status.Equals(HttpStatusCode.Created))
            {
                ParseCheck(() =>
                {
                    result.ModelPost        = ParseResponse(responseModel.Body);
                    result.Status           = EPostResponseStatus.Success;
                    result.ControllerStatus = EControllerStatus.Ok;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.Unauthorized))
            {
                ParseCheck(() =>
                {
                    result.ModelPost        = ParseResponse(responseModel.Body);
                    result.Status           = EPostResponseStatus.Unauthorized;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.BadRequest))
            {
                ParseCheck(() =>
                {
                    result.ModelPost        = ParseResponse(responseModel.Body);
                    result.Status           = EPostResponseStatus.BadRequest;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.RequestEntityTooLarge))
            {
                ParseCheck(() =>
                {
                    result.Status           = EPostResponseStatus.TooLargeImage;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }
            else if (responseModel.Status.Equals(HttpStatusCode.BadGateway))
            {
                CurrentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(new DataModelMock
                {
                    ControllerStatus = EControllerStatus.NoConnection
                });
                return;
            }
            else
            {
                ParseCheck(() =>
                {
                    result.ModelPost        = ParseResponse(responseModel.Body);
                    result.Status           = EPostResponseStatus.Error;
                    result.ControllerStatus = EControllerStatus.Error;
                });
            }

            if (result != null)
            {
                CurrentRecieveStatus = EControllerStatus.None;
                OnRecieveModel?.Invoke(result);
            }
        }