public TypeAircraftViewModel() { Title = "TypeAircraft"; TypeAircraftService = new TypeAircraftService(); SearchFilter = ""; TypeAircrafts = new ObservableCollection <TypeAircraft>(); TypeAircraft = new TypeAircraft(); Search(); }
public async Task <TypeAircraft> GetById(int id) { string responseBody; using (var client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync($"{api}/{id}"); response.EnsureSuccessStatusCode(); responseBody = await response.Content.ReadAsStringAsync(); } TypeAircraft = JsonConvert.DeserializeObject <TypeAircraft>(responseBody); return(TypeAircraft); }
public async Task Delete() { await TypeAircraftService.Delete(TypeAircraft.Id); TypeAircraft = new TypeAircraft(); NotifyPropertyChanged(() => TypeAircraft); List <TypeAircraft> tempTypeAircrafts = await TypeAircraftService.GetAll(); TypeAircrafts = new ObservableCollection <TypeAircraft>(); foreach (var fl in tempTypeAircrafts) { TypeAircrafts.Add(fl); } NotifyPropertyChanged(() => TypeAircrafts); }
public async Task Create() { TypeAircraft TypeAircraft = await TypeAircraftService.Create(this.TypeAircraft); TypeAircraft = new TypeAircraft(); List <TypeAircraft> tempTypeAircrafts = await TypeAircraftService.GetAll(); TypeAircrafts = new ObservableCollection <TypeAircraft>(); foreach (var item in tempTypeAircrafts) { TypeAircrafts.Add(item); } NotifyPropertyChanged(() => TypeAircrafts); }
public async Task <TypeAircraft> Update(TypeAircraft TypeAircraft, int id) { string responseBody; using (var client = new HttpClient()) { var stringContent = new StringContent(JsonConvert.SerializeObject(TypeAircraft), Encoding.UTF8, "application/json"); var response = await client.PutAsync($"{api}/{id}", stringContent); response.EnsureSuccessStatusCode(); responseBody = await response.Content.ReadAsStringAsync(); } TypeAircraft = JsonConvert.DeserializeObject <TypeAircraft>(responseBody); return(TypeAircraft); }
public void CreateClicked() { TypeAircraft = new TypeAircraft(); NotifyPropertyChanged(() => TypeAircraft); }
void TypeAircraftList_ItemClick(object sender, ItemClickEventArgs e) { TypeAircraft selectedTypeAircraft = (TypeAircraft)e.ClickedItem; ViewModel.TypeAircraft = selectedTypeAircraft; }