public HttpResponseMessage Post(int id, DadosPlantio obj) { try { _dadosPlantioRepository.Update(obj); return(Request.CreateResponse(HttpStatusCode.OK, new { msg = "Alterado com sucesso", success = true })); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { msg = e.Message, success = false })); } }
public async void Update(DadosPlantio dado) { try { var client = new HttpClient(); var json = JsonConvert.SerializeObject(dado); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("http://drogaterra.com.br/api/culturas/" + dado.Id, content); App.Current.MainPage.DisplayAlert("Mensagem", "Alterado com sucesso", "Ok"); } catch (Exception e) { App.Current.MainPage.DisplayAlert("Mensagem", "Não foi possivel realizar a execução", "Ok"); } }
public async void ExecutaButton() { if (String.IsNullOrEmpty(DadoPlantio.Tecnologia)) { await App.Current.MainPage.DisplayAlert("Atenção!!!", "Para realizar o Cadastro é necessário preencher o campo", "OK"); } else { DadosPlantio dado = new DadosPlantio(); dado = DadoPlantio; if (dado.Id != null) { new DadosPlantioController().Update(dado); } else { new DadosPlantioController().Cadastrar(dado); } } DadoPlantio.Tecnologia = null; }