private async Task GetData()
        {
            await Task.Delay(100); //Pantalla este construida

            View.ShowLoading();
            var response = await getRiskFactorsUseCase.Execute();

            View.HideLoading();
            if (response.ErrorCode > 0)
            {
                View.ShowDialog(response.Message, "msg_ok", null);
            }
            else
            {
                factors    = response.Data;
                actualStep = Steps.Step1;
                View.ShowFirstStep();
            }
        }
        public async Task QuestionFirstStepClicked(bool?v)
        {
            responses[0] = v;
            View.ShowLoading();
            var response = await getRiskFactorsUseCase.Execute();

            View.HideLoading();
            if (response.ErrorCode > 0)
            {
                View.ShowDialog(response.Message, "msg_ok", null);
            }
            else
            {
                var factors = response.Data;
                List <RequestValue> values = new List <RequestValue>();
                for (int i = 0; i < responses.Length; i++)
                {
                    var value = new RequestValue()
                    {
                        Id    = factors.First(x => x.Name.Equals(keys[i])).IdRiskFactor,
                        Value = responses[i]
                    };
                    values.Add(value);
                }
                var responseRisk = await senrRiskFactorsUseCase.Execute(values);

                if (responseRisk.ErrorCode > 0)
                {
                    View.HideLoading();
                    View.ShowDialog(responseRisk.Message, "msg_ok", null);
                }
                else
                {
                    View.HideLoading();
                    navigator.GoToMain();
                }
            }
        }
Exemplo n.º 3
0
        public async Task Authorized(string token)
        {
            var appSession = Locator.Current.GetService <AppSession>();

            appSession.AccesToken = token;

            View.ShowLoading();
            var userResponse = await getUserUseCase.Execute();

            if (userResponse.ErrorCode > 0)
            {
                View.HideLoading();
                if (userResponse.ErrorCode == 401)
                {
                    View.ShowDialog("error_401_user", "msg_ok", null);
                }
                else
                {
                    View.ShowDialog(userResponse.Message, "msg_ok", null);
                }
                View.ShowRetry();
            }
            else
            {
                settingsService.AddOrUpdateValue <string>(DomainConstants.LAST_SESSION, appSession.AccesToken);
                settingsService.AddOrUpdateValue <string>(DomainConstants.LAST_USER, appSession.User);
                settingsService.AddOrUpdateValue <long>(DomainConstants.LAST_DATE, DateTime.Now.Ticks);
                settingsService.AddOrUpdateValue <string>(DomainConstants.LAST_USER_INFO, JsonConvert.SerializeObject(appSession.UserInfo));
                var passportResponse = await getPassportUseCase.Execute(true);

                //await getPassportStatesUseCase.Execute(true);
                //await getPassportStatesColorsUseCase.Execute(true);
                await getRiskFactorsUseCase.Execute(true);

                await getSymptomTypesUseCase.Execute(true);

                //await getMedicalMonitorsUseCase.Execute(true);
                View.HideLoading();
                if (passportResponse.ErrorCode > 0)
                {
                    View.ShowDialog(passportResponse.Message, "msg_ok", null);
                }
                else
                {
                    if (passportResponse.Data == null)
                    {
                        //navigator.GoToMedicalTest();
                        var resFactors = await getRiskFactorsUseCase.Execute();

                        if (resFactors.ErrorCode > 0)
                        {
                            View.ShowDialog(resFactors.Message, "msg_ok", null);
                            return;
                        }
                        var factors = resFactors.Data;
                        List <RequestValue> values = new List <RequestValue>();
                        for (int i = 0; i < factors.Count(); i++)
                        {
                            var value = new RequestValue()
                            {
                                Id    = factors.ElementAt(i).IdRiskFactor,
                                Value = (bool?)null
                            };
                            values.Add(value);
                        }
                        var response = await senrRiskFactorsUseCase.Execute(values);

                        if (response.ErrorCode > 0)
                        {
                            View.ShowDialog(response.Message, "msg_ok", null);
                        }
                        else
                        {
                            navigator.GoToMain();
                        }
                    }
                    else
                    {
                        navigator.GoToMain();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private async Task GoLogin()
        {
            var  settingsService = Locator.Current.GetService <ISettingsService>();
            long ticks           = settingsService.GetValueOrDefault <long>(DomainConstants.LAST_DATE, 0);

            if (ticks == 0)
            {
                navigator.GoToLogin();
                return;
            }

            /*DateTime last = new DateTime(ticks);
             * if (!DateTime.Now.ToString("yyyy-MM-dd").Equals(last.ToString("yyyy-MM-dd")))
             * {
             *  navigator.GoToLogin();
             *  return;
             * }*/
            String token = settingsService.GetValueOrDefault <string>(DomainConstants.LAST_SESSION);

            if (token == null || token.Trim().Equals(""))
            {
                navigator.GoToLogin();
                return;
            }
            var appSession = Locator.Current.GetService <AppSession>();

            appSession.AccesToken = token;
            appSession.User       = settingsService.GetValueOrDefault <string>(DomainConstants.LAST_USER);
            string userInfo = settingsService.GetValueOrDefault <string>(DomainConstants.LAST_USER_INFO);

            if (userInfo != null)
            {
                appSession.UserInfo = JsonConvert.DeserializeObject <User>(userInfo);
            }
            View.ShowLoading();
            var passportResponse = await getPassportUseCase.Execute(true);

            //await getPassportStatesUseCase.Execute(true);
            //await getPassportStatesColorsUseCase.Execute(true);
            await getRiskFactorsUseCase.Execute(true);

            await getSymptomTypesUseCase.Execute(true);

            //await getMedicalMonitorsUseCase.Execute(true);
            View.HideLoading();
            //navigator.GoToOffline();
            //return;
            if (passportResponse.ErrorCode > 0)
            {
                if (passportResponse.ErrorCode == 401)
                {
                    navigator.GoToLogin();
                }
                else if (passportResponse.ErrorCode == 500)
                {
                    navigator.GoToLogin();
                }
                else
                {
                    var passport = getOfflinePassportUseCase.Execute();
                    if (passport == null)
                    {
                        navigator.GoToLogin();
                    }
                    else
                    {
                        navigator.GoToOffline();
                    }
                }
            }
            else
            {
                if (passportResponse.Data == null)
                {
                    navigator.GoToLogin();// En el login tenemos botón de reintentar  navigator.GoToMedicalTest();
                }
                else
                {
                    navigator.GoToMain();
                }
            }
        }