//добавление private async void Bt_add_Clicked(object sender, EventArgs e) { try { ApiService api = new ApiService { Url = ApiService.URL_ADD_RETAIL }; Dictionary<string, string> data = new Dictionary<string, string>(); data.Add("auth_key", App.APP.CurrentUser.AuthKey); if (en_item_title.Text == null || en_item_title.Text.Length == 0) throw new Exception("Title must be fill!"); data.Add("title", en_item_title.Text); if(retailPoints==null || retailPoints.Count==0) throw new Exception("Retails not found!"); RetailPoint point = retailPoints.Where(x => (x.Title == en_item_retail.Text.Split('\n')[0])).FirstOrDefault(); if(point==null) throw new Exception("Retail point not found!"); data.Add("retailer_id", point.Id.ToString()); var res = await api.Post(data); if(res == System.Net.HttpStatusCode.OK) { await DisplayAlert("Succees", "Network was added", "OK"); await Navigation.PopModalAsync(true); } else { await DisplayAlert("Warning", "Network was not added", "Done"); } } catch(Exception ex) { await DisplayAlert("Error", ex.Message, "Done"); } }//Bt_add_Clicked
internal AddNetworkPage (RetailPoint _point) { InitializeComponent (); currentPoint = _point; lb_title.Text = "Add new network"; lb_item_title.Text = "New title"; en_item_title.Placeholder = "Put title"; lb_item_network.Text = "New network"; lb_item_retail.Text = "New Retail"; en_item_retail.Placeholder = "Select retail point"; bt_add.Text = "Add"; bt_edit.Text = "Edit"; bt_delete.Text = "Remove"; bt_back.Text = "Back"; en_item_retail.Focused += En_item_retail_Focused; pc_item_network.Focused += Pc_item_network_Focused; en_item_title.Focused+= Pc_item_network_Focused; bt_back.Clicked += Bt_back_Clicked; bt_add.Clicked += Bt_add_Clicked; bt_delete.Clicked += Bt_delete_Clicked; bt_edit.IsVisible = false; }//c_tor