Beispiel #1
0
        public static async Task <List <MeusAds> > GetMeusAds()
        {
            await TokenValidator.CheckTokenValidade();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.GetStringAsync(AppSettings.ApiUrl + "api/veiculos/MeusAds");

            return(JsonConvert.DeserializeObject <List <MeusAds> >(resposta));
        }
Beispiel #2
0
        public static async Task <VeiculoDetalhe> GetVeiculosDetalhe(int id)
        {
            await TokenValidator.CheckTokenValidade();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.GetStringAsync(AppSettings.ApiUrl + $"api/Veiculos/DetalhesVeiculos?id={id}");

            return(JsonConvert.DeserializeObject <VeiculoDetalhe>(resposta));
        }
Beispiel #3
0
        public static async Task <UserImageModel> GetUserImage()
        {
            await TokenValidator.CheckTokenValidade();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.GetStringAsync(AppSettings.ApiUrl + "api/contas/UserProfileImage");

            return(JsonConvert.DeserializeObject <UserImageModel>(resposta));
        }
Beispiel #4
0
        public static async Task <bool> ExcluirVeiculo(int id)
        {
            await TokenValidator.CheckTokenValidade();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.DeleteAsync(AppSettings.ApiUrl + $"api/Veiculos/ExcluirVeiculo/{id}");

            if (!resposta.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        public static async Task <bool> EditarFotoPerfil(byte[] imageArray)
        {
            await TokenValidator.CheckTokenValidade();

            var json    = JsonConvert.SerializeObject(imageArray);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.PostAsync(AppSettings.ApiUrl + "api/contas/Editarperfil", content);

            if (!resposta.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
Beispiel #6
0
        public static async Task <bool> AddImage(int veiculoId, byte[] imageArray)
        {
            var ImageVeiculo = new VeiculoImageModel()
            {
                VeiculoId  = veiculoId,
                ImageArray = imageArray
            };
            await TokenValidator.CheckTokenValidade();

            var json    = JsonConvert.SerializeObject(ImageVeiculo);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.PostAsync(AppSettings.ApiUrl + "api/images", content);

            if (!resposta.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
Beispiel #7
0
        public static async Task <bool> EditarNumeroTelefone(string telefone)
        {
            await TokenValidator.CheckTokenValidade();

            var telefoneobj = new Telefone()
            {
                telefone = telefone
            };
            await TokenValidator.CheckTokenValidade();

            var json    = JsonConvert.SerializeObject(telefoneobj);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.PostAsync(AppSettings.ApiUrl + "api/contas/trocartelefone", content);

            if (!resposta.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
Beispiel #8
0
        public static async Task <bool> TrocarSenha(string senhaAntiga, string novaSenha, string confirmarSenha)
        {
            var trocarsenha = new TrocarSenhaModel()
            {
                SenhaAntiga    = senhaAntiga,
                NovaSenha      = novaSenha,
                ConfirmarSenha = confirmarSenha
            };
            await TokenValidator.CheckTokenValidade();

            var json    = JsonConvert.SerializeObject(trocarsenha);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get("accessToken", string.Empty));
            var resposta = await httpClient.PostAsync(AppSettings.ApiUrl + "api/contas/trocarsenha", content);

            if (!resposta.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }