Exemplo n.º 1
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.º 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)
        {
            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.º 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
        private void ParseRates(HttpStatusCode statusCode, JArray args)
        {
            var result = new DataModelListQc();

            if (statusCode.Equals(HttpStatusCode.OK))
            {
                try
                {
                    _repository.UpdateQc(_parseResponseQc(args));
                    result.QcUpdatedList = _repository.UpdatedQuotations;
                    result.Status        = EQcResponseStatus.Success;
                }
                catch (ParseException)
                {
                    result.Status = EQcResponseStatus.Error;
                }
            }
            else if (statusCode.Equals(HttpStatusCode.Gone))
            {
                result.Status = EQcResponseStatus.Gone;
            }
            else
            {
                result.Status = EQcResponseStatus.Error;
            }

            OnRecieveModel?.Invoke(result);
        }
Exemplo n.º 6
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.º 7
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.º 8
0
 private void AllPostsIncome(List <string> obj)
 {
     if (obj != null && obj.Count != 0)
     {
         OnRecieveModel?.Invoke(new PostIds(obj)
         {
             ControllerStatus = EControllerStatus.Ok
         });
     }
 }
Exemplo n.º 9
0
        public void Send(IModelSend senderModel)
        {
            if (!(senderModel is CurrentPostIdRequest model))
            {
                return;
            }

            var onePost = _repositoryPost.GetOnePostById(model.CurrentPostId);

            onePost.Status = EPostResponseStatus.Success;

            OnRecieveModel?.Invoke(onePost);
        }
Exemplo n.º 10
0
        public void Send(IModelSend senderModel)
        {
            if (!(senderModel is UserInfoRequestModel model))
            {
                return;
            }

            var userData = new DataModelProfileCell(_repositoryUser.AuthData.Name, _repositoryUser.AuthData.Image)
            {
                ControllerStatus = EControllerStatus.Ok
            };

            OnRecieveModel?.Invoke(userData);
        }
Exemplo n.º 11
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.º 12
0
        public void Send(IModelSend senderModel)
        {
            var contact = ContactCreator.CreateContact(senderModel);

            contact.Reciever = this;
            if (_currentRecieveStatus != EControllerStatus.Processing)
            {
                var processingModel = new DataModelMock
                {
                    ControllerStatus = EControllerStatus.Processing
                };
                _currentRecieveStatus = processingModel.ControllerStatus;
                OnRecieveModel?.Invoke(processingModel);
                contact.Sender.Send(senderModel);
            }
        }
Exemplo n.º 13
0
 private void ParseCheck(Action action)
 {
     try
     {
         action?.Invoke();
     }
     catch (ParseException)
     {
         OnRecieveModel?.Invoke(
             new DataModelMock
         {
             ControllerStatus = EControllerStatus.Error
         }
             );
     }
 }
Exemplo n.º 14
0
 protected void ParseCheck(Action action)
 {
     try
     {
         action?.Invoke();
     }
     catch (ParseException)
     {
         CurrentRecieveStatus = EControllerStatus.None;
         OnRecieveModel?.Invoke(
             new DataModelMock()
         {
             ControllerStatus = EControllerStatus.Error
         }
             );
     }
 }
Exemplo n.º 15
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.º 16
0
        public void Send(IModelSend model)
        {
            if (model is PostsRequestModel)
            {
                var result = new List <DataModelPost>
                {
                    new DataModelPost("111", "111", "AUDJPY", "Currency", "Buy", 12.23f, "Public", "http://www.meridianpeakhypnosis.com/wp-content/uploads/2014/02/money-addiction.jpg", "Hello", "2017-07-24T00:00:01.00Z", "2017-07-25T00:00:01.00Z", null, "Jon Snow", "https://pbs.twimg.com/profile_images/901947348699545601/hqRMHITj.jpg", 2, 5, true),
                    new DataModelPost("222", "222", "AUDCAD", "Currency", "Buy", 58.45f, "Public", null, "This method reloads all the data in the table, including cells, headers, footers and the index array. For efficiency, only visible rows are have their cells loaded and displayed. A table view's UITableView.Source calls this method when it wants to completely reload data. This method should not be called inside other methods that insert or delete rows, especially within a UITableView.BeginUpdates-UITableView.EndUpdates animation block.", "2017-07-24T00:00:01.00Z", "2017-07-25T00:00:01.00Z", null, "Petr Ivanov", "https://bhi61nm2cr3mkdgk1dtaov18-wpengine.netdna-ssl.com/wp-content/uploads/2017/03/pig_thm.jpg", 7, 8, false),
                    new DataModelPost("333", "333", "AUDUSD", "Currency", "Sell", 58.45f, "Public", null, "Why do you want to use a TableView? Answering this question is important to implementing a proper solution. If you are going to potentially have a lot of rows in the TableView, you will have to get creative with your solution. I want to help, but need some more guidance of what you are trying to achieve in the application with this TableView (like is it a settings page, or displaying dynamic rows to users etc.", "2017-07-24T00:00:01.00Z", "2017-07-25T00:00:01.00Z", null, "Petr Azarov", null, 11, 3, false)
                };

                Service.DataService.RepositoryController.RepositoryPost.SetPosts(result.Distinct().ToDictionary(key => key.Id, value => value));

                var postsModel = new postMockModel(Service.DataService.RepositoryController.RepositoryPost.GetPostIds());
                postsModel.ControllerStatus = EControllerStatus.Ok;

                OnRecieveModel?.Invoke(postsModel);
            }
        }
Exemplo n.º 17
0
        public virtual void Send(IModelSend senderModel)
        {
            if (CurrentRecieveStatus == EControllerStatus.Processing)
            {
                return;
            }

            var contact = ContactCreator.CreateContact(senderModel);

            contact.Reciever = this;

            var processingModel = new DataModelMock
            {
                ControllerStatus = EControllerStatus.Processing
            };

            CurrentRecieveStatus = processingModel.ControllerStatus;
            OnRecieveModel?.Invoke(processingModel);
            contact.Sender.Send(senderModel);
        }
Exemplo n.º 18
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.º 19
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.º 20
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);
            }
        }