This repository has been archived by the owner on Mar 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5d20ae
commit d956dd9
Showing
14 changed files
with
190 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using GeradorNF.Model; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace GeradorNF.DAO | ||
{ | ||
public class ClienteDAO | ||
{ | ||
/// <summary> | ||
/// GetCliente - Buscar/Listar TODOS os Emitentes | ||
/// </summary> | ||
/// <returns></returns> | ||
public static async Task<Cliente> GetClienteByIdDAO(string nomeUsuario) | ||
{ | ||
try | ||
{ | ||
using (var client = new HttpClient()) | ||
{ | ||
client.BaseAddress = new Uri(UtilDAO.UrlApi()); | ||
client.DefaultRequestHeaders.Accept.Clear(); | ||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
|
||
HttpResponseMessage response = await client.GetAsync("cliente/" + nomeUsuario); | ||
|
||
if (response.IsSuccessStatusCode) | ||
{ | ||
string json = await response.Content.ReadAsStringAsync(); | ||
return Newtonsoft.Json.JsonConvert.DeserializeObject<Cliente>(json); | ||
} | ||
else | ||
throw new Exception(response.RequestMessage.ToString()); | ||
} | ||
} | ||
catch (JsonException ex) | ||
{ | ||
throw new Exception("JsonException - Não foi possivel buscar o cliente. Erro: " + ex.Message); | ||
} | ||
catch (HttpRequestException ex) | ||
{ | ||
throw new Exception("HttpRequestException - Não foi possivel buscar o cliente. Erro: " + ex.Message); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new Exception("Exception - Não foi possivel buscar os Emitentes. Erro: " + ex.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using GeradorNF.Model; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace GeradorNF.UI | ||
{ | ||
public static class MyGlobals | ||
{ | ||
public static string Cliente = "https://geradornf-prod.herokuapp.com/cliente/1/"; //hardcode - Tirar | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters