public async Task <LotMobile> GetByLotCode(string LotCode) { try { if (string.IsNullOrEmpty(LotCode)) { return(await Task.FromResult(new LotMobile(false, "Usuário e/ou senha inválidos"))); } else { using (var client = new HttpClient()) { var response = client.GetAsync(string.Format(Constants.WebServiceEndPoint + Constants.LotEndPoint + "getbylotcode/" + LotCode)).Result; var json = await response.Content.ReadAsStringAsync(); if (response.StatusCode.Equals(HttpStatusCode.OK)) { LotMobile lotResponse = JsonConvert.DeserializeObject <LotMobile>(json); lotResponse.Success = true; return(await Task.FromResult(lotResponse)); } else { MobileException exception = JsonConvert.DeserializeObject <MobileException>(json); return(await Task.FromResult(new LotMobile(false, exception.Message))); } } } } catch (Exception e) { return(null); } }
public void InformacoesParaPagina(LotMobile lot) { if (lot != null) { stackLot.IsVisible = true; if (DependencyService.Get <IFCMInfosGetter>().isSubscribedToTopic("follow." + lot.Code)) { btnSeguir.Text = "Deixar de seguir"; isSubscribed = true; } else { btnSeguir.Text = "Seguir"; isSubscribed = false; } LotCode = lot.Code; lblCod.Text = lot.Code; lblValidade.Text = lot.Vality.ToString(); ListViewProduct.ItemsSource = lot.ListProduct; ListAnalysis = lot.ListAnalysis; } }