private async void Save_Clicked(object sender, EventArgs e) { var client = new RestClient(Settings.AdirApiUrl); var request = new RestRequest("diseaseincident", DataFormat.Json); var diseaseincident = new Models.DiseaseIncident(); var DiseaseIncidentViewModel = new DiseaseIncidentViewModel(); diseaseincident.ReportedByFirstname = FirstName.Text; diseaseincident.ReportedByMiddleName = MiddleName.Text; diseaseincident.ReportedByLastname = LastName.Text; diseaseincident.ReportedBySuffixName = ExtensionName.Text; diseaseincident.ContactNumber = ContactNumber.Text; diseaseincident.ContactPerson = ContactPerson.Text; diseaseincident.SymptomsStartDate = Symptoms.Date; diseaseincident.DeceasedDate = AnimalDied.Date; diseaseincident.NumberOfDeaths = Convert.ToInt32(Deaths.Text); diseaseincident.NumberOfInfected = Convert.ToInt32(Infected.Text); diseaseincident.Population = Convert.ToInt32(Population.Text); diseaseincident.Symptoms = WhatSymptoms.Text; diseaseincident.Notes = Remarks.Text; var brgy = BarangaySelect.SelectedItem as Barangay; diseaseincident.Barangay = brgy; //diseaseincident.SpeciesName = ""; diseaseincident.BarangayId = (int)brgy.BarangayId; diseaseincident.Longitude = 0; diseaseincident.Latitude = 0; // diseaseincident.SpeciesId = DiseaseIncidentViewModel.SelectedSpecies.SpeciesId; var spcs = SpeciesSelect.SelectedItem as Models.SpeciesDTO; diseaseincident.SpeciesId = (int)spcs.SpeciesId; diseaseincident.IsActive = true; diseaseincident.CreatedByAppUserId = 1; diseaseincident.CreatedOn = DateTime.Now; request.Method = Method.POST; request.AddJsonBody(diseaseincident); var response = await client.ExecuteAsync(request); var productData = JsonConvert.DeserializeObject <DiseaseIncident>(response.Content); if (response.StatusCode == System.Net.HttpStatusCode.Created) { // await UploadPhoto(diseaseincident.DiseaseIncidentId); await DisplayAlert("Information", "Product successfully added", "OK"); // await Navigation.PopModalAsync(); // await _mainpage.ExecuteLoadProductsCommand(); } else { await DisplayAlert("Warning", "An Error occured while creating", "OK"); } }
// public ObservableCollection<Species> Provinces { get; set; } // public DiseaseIncident Incident { get; set; } //public DiseaseIncident(App mainPage) //{ // InitializeComponent(); // _mainpage = mainPage; // BindingContext = this; //} public DiseaseIncident() { //_mainpage = mainPage; DiseaseIncidentViewModel DiseaseBinding = new DiseaseIncidentViewModel(); BindingContext = DiseaseBinding; InitializeComponent(); ExecuteLoadRegionCommand(); LoadSpecies(); }