예제 #1
0
 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 }));
     }
 }
예제 #2
0
        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");
            }
        }
예제 #3
0
        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;
        }