Ejemplo n.º 1
0
 private async void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
 {
     if (e.SelectedItem == null)
     {
         return;
     }
     else
     {
         AutomobiliModel model = e.SelectedItem as AutomobiliModel;
         await Navigation.PushAsync(new NavigationPage(new UserCarPage(model)));
     }
 }
Ejemplo n.º 2
0
        public async Task <string> InsertCar(AutomobiliModel model)
        {
            string res = string.Empty;

            HttpResponseMessage httpResponse = new HttpResponseMessage();
            var json          = JsonConvert.SerializeObject(model);
            var stringContent = new StringContent(json, Encoding.UTF8, "application/json");

            client.DefaultRequestHeaders.Add("Accept", "application/json");
            client.DefaultRequestHeaders.Add("Host", "localhost");
            try
            {
                httpResponse = client.PostAsJsonAsync(@"http://10.0.2.2:58830/api/Cars", model).Result;
                if (httpResponse.StatusCode == System.Net.HttpStatusCode.OK || httpResponse.StatusCode == System.Net.HttpStatusCode.NoContent)
                {
                    res = "OK";
                }
            }
            catch (Exception ex)
            {
                res = "failed";
            }
            return(res);
        }
 public CreateCarPageModel()
 {
     GetAllBrands();
     CarModel = new AutomobiliModel();
 }
 public CarPageViewModel(AutomobiliModel model)
 {
     automobiliModel = model;
     GetComments(automobiliModel.AutomobilID);
 }
 public UserCarPage(AutomobiliModel model)
 {
     InitializeComponent();
     BindingContext = new UserCarPageViewModel(model);
 }