}     //This method confirms if the login was valid

        public async Task <bool> FicMetAddUser(temp_model_add_user FicDataUser)
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    string FicUrl = FicAppSettings.FicUrlBase.ToString() + "api/seguridad/nuevo_registro";

                    var response = await FicHttpClient.PostAsync(FicUrl, new StringContent(JsonConvert.SerializeObject(FicDataUser)));

                    if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        await new Page().DisplayAlert("ALERTA", response.Content.ReadAsStringAsync().ToString(), "OK");
                        return(false);
                    }
                    else if (response.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        await new Page().DisplayAlert("ALERTA", "StatusCode: " + response.StatusCode.ToString(), "OK");
                        return(false);
                    }
                    //var FicMessageResponse = await response.Content.ReadAsStringAsync();
                    await new Page().DisplayAlert("REGISTRADO CON EXITO", await response.Content.ReadAsStringAsync(), "OK");

                    return(true);
                }
                await new Page().DisplayAlert("ALERTA", "Sin Conexion a internet.", "OK");
                return(false);
            }
            catch (Exception e)
            {
                await new Page().DisplayAlert("ALERTA", e.Message.ToString(), "OK");
                return(false);
            }
        }//This method confirms
示例#2
0
        }//GET: This method receives the information to manage the login locally

        public async Task <bool> FicMetAddUser(temp_model_add_user FicDataUser)
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected(1))
                {
                    string url = FicAppSettings.FicURLBase.ToString() + "api/seguridad/nuevo_registro";
                    //var response = await FicHttpClient.PostAsync(url, new StringContent(JsonConvert.SerializeObject(FicDataUser)));
                    HttpResponseMessage response = await FicHttpClient.PostAsync(
                        new Uri(string.Format(url, string.Empty)),
                        new StringContent(JsonConvert.SerializeObject(FicDataUser), Encoding.UTF8, "application/json"));

                    var respuesta = await response.Content.ReadAsStringAsync();

                    if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        await App.Current.MainPage.DisplayAlert("ALERTA", respuesta, "OK");

                        return(false);
                    }
                    else if (response.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        await App.Current.MainPage.DisplayAlert("ALERTA", "StatusCode: " + response.StatusCode.ToString(), "OK");

                        return(false);
                    } //var FicMessageResponse = await response.Content.ReadAsStringAsync();
                    await App.Current.MainPage.DisplayAlert("REGISTRADO CON EXITO", await response.Content.ReadAsStringAsync(), "CK");

                    return(true);
                }
                await App.Current.MainPage.DisplayAlert("ALERTA", "Sin Conexion a internet.", "OK");

                return(false);
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("AERTA.", e.Message.ToString(), "OK");

                return(false);
            }
        }//This method confirms