private void ButtonForm_Clicked(object sender, EventArgs e)
        {
            Incident LIncident = new Incident();

            FDataHora = dtpDateHour.Date;
            FDataHora = FDataHora.Add(FHour);

            LIncident.CreateIncident(FCurrentCategory, App.CurrentUser, FDescription, FDataHora, LPosX, LPosY);
            // async Task<ICollection<IncidentCategory>> IncidentForm()
            // {
            try
            {
                string url     = "https://tmappwebapi20180922043720.azurewebsites.net/api/Incident";
                var    json    = JsonConvert.SerializeObject(LIncident);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");
                var    result  = FCliente.PostAsync(url, content);

                result.Wait();

                DisplayAlert("Aviso", "OcorrĂȘncia adicionada com sucesso!", "OK");
                Application.Current.MainPage.Navigation.PopAsync();
                IncidentFilter LFilter = new IncidentFilter();
                Application.Current.MainPage.Navigation.PushAsync(new MapPage(LFilter));
                Navigation.PopModalAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return;
            // }
        }
Example #2
0
        public void ButtonForm_Clicked(object sender, EventArgs e)
        {
            //Substitui os valores da classe pelos valores dos campos
            FDescription          = xDescription.Text;
            FIncident.Description = FDescription;
            FDataHora             = FDataHora.Date;
            FDataHora.Add(FHour);
            FIncident.DataHora   = FDataHora;
            FIncident.IdCategory = FCurrentCategory.IdCategory;
            FIncident.Category   = FCurrentCategory;

            try
            {
                HttpClient FCliente = new HttpClient();
                string     url      = "https://tmappwebapi20180922043720.azurewebsites.net/api/IncidentEdit";
                var        json     = JsonConvert.SerializeObject(FIncident);
                var        content  = new StringContent(json, Encoding.UTF8, "application/json");
                var        result   = FCliente.PostAsync(url, content);

                result.Wait();

                DisplayAlert("Aviso", "OcorrĂȘncia alterada com sucesso!", "OK");
                Application.Current.MainPage.Navigation.PopAsync();
                IncidentFilter LFilter = new IncidentFilter();
                Application.Current.MainPage.Navigation.PushAsync(new MapPage(LFilter));
                Navigation.PopModalAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }