Beispiel #1
0
        private async Task <string> GuardaImagen(int IDusuario)
        {
            try
            {
                var dirotro = "";

                if (string.IsNullOrEmpty(VariablesGlobales.RutaImagene))
                {
                    //  await Mensajes.Alerta("Ninguna foto subida");

                    return("Error");
                }
                else
                {
                    byte[] ImagenSubir = File.ReadAllBytes(VariablesGlobales.RutaImagene);

                    int tamano = ImagenSubir.Length;

                    dirotro = Convert.ToBase64String(ImagenSubir);
                }

                var content = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("usu_id", Convert.ToString(IDusuario)),
                    new KeyValuePair <string, string>("usu_imagenstr", dirotro)
                });


                var response = await this.apiService.Get <ImagenReturn>("/usuarios", "/carga_foto", content);


                if (!response.IsSuccess)
                {
                    await Mensajes.Alerta("Error al cargar la foto, intenta de nuevo");

                    UserDialogs.Instance.HideLoading();

                    return("Error");
                }

                ListImagen = (ImagenReturn)response.Result;

                //await Mensajes.Alerta("Imagen actualizada correctamente");

                // Application.Current.Properties["FotoPerfil"] = VariablesGlobales.RutaServidor + ListImagen.resultado;

                //  await Application.Current.SavePropertiesAsync();

                return(VariablesGlobales.RutaServidor + ListImagen.resultado);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
        private async Task <string> GuardaImagen(int UsuarioID)
        {
            var dirotro = "";

            if (string.IsNullOrEmpty(VariablesGlobales.RutaImagene))
            {
                await Mensajes.Alerta("Ninguna foto subida");

                return("Error");
            }
            else
            {
                byte[] ImagenSubir = File.ReadAllBytes(VariablesGlobales.RutaImagene);

                dirotro = Convert.ToBase64String(ImagenSubir);
            }

            var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("usu_id", Convert.ToString(UsuarioID)),
                new KeyValuePair <string, string>("usu_imagenstr", dirotro)
            });


            var response = await this.apiService.Get <ImagenReturn>("/usuarios", "/carga_foto", content);


            if (!response.IsSuccess)
            {
                await Mensajes.Alerta("Error al cargar la foto, intenta de nuevo");

                UserDialogs.Instance.HideLoading();

                return("Error");
            }

            ListImagen = (ImagenReturn)response.Result;


            return(VariablesGlobales.RutaServidor + ListImagen.resultado);
        }