コード例 #1
0
        public async Task <LaboratoryMobile> GetByLaboratoryCode(string LaboratoryCode)
        {
            try
            {
                if (string.IsNullOrEmpty(LaboratoryCode))
                {
                    return(await Task.FromResult(new LaboratoryMobile(false, "Laboratório inválido")));
                }
                else
                {
                    using (var client = new HttpClient())
                    {
                        var response = client.GetAsync(string.Format(Constants.WebServiceEndPoint + Constants.LaboratoryEndPoint + "getbylaboratorycode/" + LaboratoryCode)).Result;
                        var json     = await response.Content.ReadAsStringAsync();

                        if (response.StatusCode.Equals(HttpStatusCode.OK))
                        {
                            LaboratoryMobile laboratoryResponse = JsonConvert.DeserializeObject <LaboratoryMobile>(json);
                            laboratoryResponse.Success = true;
                            return(await Task.FromResult(laboratoryResponse));
                        }
                        else
                        {
                            MobileException exception = JsonConvert.DeserializeObject <MobileException>(json);
                            return(await Task.FromResult(new LaboratoryMobile(false, exception.Message)));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #2
0
 public void InformacoesParaPagina(LaboratoryMobile laboratory)
 {
     if (laboratory != null)
     {
         lblNome.Text   = laboratory.Name;
         lblCidade.Text = laboratory.City;
         lblCnpj.Text   = laboratory.CNPJ.ToString();
         lblCodigo.Text = laboratory.Code;
     }
 }