コード例 #1
0
 public TypeAircraftViewModel()
 {
     Title = "TypeAircraft";
     TypeAircraftService = new TypeAircraftService();
     SearchFilter        = "";
     TypeAircrafts       = new ObservableCollection <TypeAircraft>();
     TypeAircraft        = new TypeAircraft();
     Search();
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void CreateClicked()
 {
     TypeAircraft = new TypeAircraft();
     NotifyPropertyChanged(() => TypeAircraft);
 }
コード例 #7
0
        void TypeAircraftList_ItemClick(object sender, ItemClickEventArgs e)
        {
            TypeAircraft selectedTypeAircraft = (TypeAircraft)e.ClickedItem;

            ViewModel.TypeAircraft = selectedTypeAircraft;
        }