async void EditCountryCommand(DAL.Models.Country country) { MessagingCenter.Subscribe <EditCountryPage, DAL.Models.Country>(this, "ChangeCountry", (sender, arg) => { //this.LoadItemsCommand(); if (arg != null) { var pos = Items.IndexOf(Items.Where(x => x.id == arg.id).FirstOrDefault()); if (pos >= 0) { Items[pos] = arg; } else //no existe { Items.Add(arg); } } }); var edit = new Views.Modals.EditCountryPage(country) { CloseWhenBackgroundIsClicked = true }; await Navigation.PushPopupAsync(edit); }
public SubdivisionListViewModel(INavigation nav, Page _page, DAL.Models.Country _country) { Navigation = nav; page = _page; country = _country; LoadItems = new Command(LoadItemsCommand); EditSubdivision = new Command <DAL.Models.Subdivision>(EditSubdivisionCommand); Delete = new Command <DAL.Models.Subdivision>(DeleteCommand); NewSubdivision = new Command(NewSubdivisionCommand); Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged; this.Title = $"{country.name} ({country.alpha2})"; }
public EditCountryViewModel(INavigation nav, Page _page, DAL.Models.Country _country) { Navigation = nav; page = _page; if (_country == null) { _country = new DAL.Models.Country(); } country = _country; Code = country.code?.ToString(); Alpha2 = country.alpha2; Alpha3 = country.alpha3; Name = country.name; IsIndependent = country.is_independent.GetValueOrDefault(); Save = new Command(SaveCommand); CloseModal = new Command(CloseModalCommand); }
public EditSubdivisionViewModel(INavigation nav, Page _page, DAL.Models.Country _country, DAL.Models.Subdivision _sub) { Navigation = nav; page = _page; if (_country == null) { _country = new DAL.Models.Country(); } if (_sub == null) { _sub = new DAL.Models.Subdivision(); } country = _country; subdivision = _sub; Code = subdivision.code; Name = subdivision.name; Save = new Command(SaveCommand); CloseModal = new Command(CloseModalCommand); }
async void DeleteCommand(DAL.Models.Country country) { if (country.id.HasValue) { var answer = await page.DisplayAlert("Delete", $"Do you wan't to delete the country {country.name}?", "Yes", "No"); if (answer) { var data = await new DAL.Country().DeleteAsync(country.id.Value); if (data != null && data.Error != null && data.Error.errorMessages?.Count > 0) { await page.DisplayAlert("Country", data.Error.errorMessages[0], "Ok"); } else { items.Remove(country); } } } }
public EditCountryPage(DAL.Models.Country _country) { InitializeComponent(); BindingContext = new EditCountryViewModel(this.Navigation, this, _country); }
public EditSubdivisionPage(DAL.Models.Country country, DAL.Models.Subdivision subdivision) { InitializeComponent(); BindingContext = new EditSubdivisionViewModel(this.Navigation, this, country, subdivision); }
public SubdivisionListPage(DAL.Models.Country _country) { InitializeComponent(); BindingContext = new SubdivisionListViewModel(this.Navigation, this, _country); }
async void SearchSubdivisionCommand(DAL.Models.Country country) { await Navigation.PushAsync(new SubdivisionListPage(country)); }