private async Task Accept()
        {
            if (Validate())
            {
                try
                {
                    ApiClientOption option = new ApiClientOption
                    {
                        RequestType    = ApiClientRequestTypes.Post,
                        Uri            = "api/login/create",
                        Service        = ApiClientServices.Api,
                        RequestContent = new { Nombre = $"{Name} {Surname}", Password, Telefono = Telephone, Email }
                    };

                    await apiClient.InvokeDataServiceAsync(option);

                    await dialogService.DisplayAlertAsync("Registro", "Se registró correctamente", "Aceptar");

                    await NavigationService.GoBackAsync();
                }
                catch
                {
                    await dialogService.DisplayAlertAsync("Registro", "Ocurrió un error al realizar la operación. Intente nuevamente en unos minutos.", "Aceptar");
                }
            }
        }
Beispiel #2
0
        private async Task NextAsync()
        {
            if (Validate())
            {
                try
                {
                    var             user   = Helper.GetApplicationValue <string>("user");
                    ApiClientOption option = new ApiClientOption
                    {
                        RequestType    = ApiClientRequestTypes.Post,
                        Uri            = "api/changePassword",
                        Service        = ApiClientServices.Api,
                        RequestContent = new { user, NewPassword }
                    };

                    await apiClient.InvokeDataServiceAsync(option);

                    await dialogService.DisplayAlertAsync("Cambiar contraseña", "Su contraseña se cambio con éxito", "Aceptar");

                    await NavigationService.GoBackAsync();
                }
                catch
                {
                    await dialogService.DisplayAlertAsync("Cambiar contraseña", "Ocurrió un error al realizar la operación. Intente nuevamente en unos minutos.", "Aceptar");
                }
            }
        }
        private async Task Accept()
        {
            if (Validate())
            {
                try
                {
                    ApiClientOption option = new ApiClientOption
                    {
                        RequestType    = ApiClientRequestTypes.Post,
                        Uri            = "api/register",
                        Service        = ApiClientServices.Api,
                        RequestContent = new { Email }
                    };

                    await apiClient.InvokeDataServiceAsync(option);

                    await dialogService.DisplayAlertAsync("Recuperar contraseña", "Enviamos un mail a su casilla para que recupere su contraseña", "Aceptar");

                    await NavigationService.GoBackAsync();
                }
                catch
                {
                    await dialogService.DisplayAlertAsync("Recuperar contraseña", "Ocurrió un error al realizar la operación. Intente nuevamente en unos minutos.", "Aceptar");
                }
            }
        }
        private async Task LoginAsync()
        {
            Message   = null;
            IsLoading = true;

            try
            {
                if (Validate())
                {
                    var options = new ApiClientOption
                    {
                        RequestType    = ApiClientRequestTypes.Post,
                        Uri            = "api/login",
                        Service        = ApiClientServices.Api,
                        RequestContent = new { Email = User, Password }
                    };

                    LoginResult result = await apiClient.InvokeDataServiceAsync <LoginResult>(options);
                    await GoToMenu(result.Token);
                }
            }
            catch (Exception e)
            {
                string message = "Unauthorized".Equals(e.Message) ? "Las credenciales ingresadas son incorrectas." : "Ocurrió un error al ingresar. Intente nuevamente en unos minutos.";

                await dialogService.DisplayAlertAsync("Error", message, "Aceptar");
            }
            finally
            {
                IsLoading = false;
            }
        }
        private object GetApiInstance()
        {
            var type   = (Type)bindingSourceClass.Current;
            var option = new ApiClientOption(textBoxKey.Text, textBoxSecret.Text);

            return(Activator.CreateInstance(type, new[] { option }));
        }
        public void HttpStatusCodesToRetry_setter_should_throw_ArgumentNullException_if_value_is_null()
        {
            //arrange
            var obj = new ApiClientOption();

            //act
            var actual = Record.Exception(() => obj.HttpStatusCodesToRetry = null);

            //assert
            Assert.IsType <ArgumentNullException>(actual);
        }
Beispiel #7
0
        public void Construtcor_should_return_instance_2(ApiClientOption option)
        {
            //arrange

            //act
            var obj = new FutureApi(option);

            //assert
            Assert.NotNull(obj);
            Assert.IsType <FutureApi>(obj);
        }
Beispiel #8
0
 // IApiClientのファクトリ(ApiClientOptionを指定可)
 internal static IApiClient CreateApiClientWithMockHttpAccessor(ApiClientOption option)
 => new ApiClient("http://localhost", option);
 public HomeController(IHttpClientProvider httpClientProvider, IOptions <ApiClientOption> apiClientOption)
 {
     _apiClientOption    = apiClientOption.Value;
     _httpClientProvider = httpClientProvider;
 }