public async Task DeleteZone(object obj) { if (NotNetOrConnection) { return; } try { ZoneViewModel zvm = (ZoneViewModel)obj; State = ModelState.Loading; Zone zone = new Zone(); zvm.SaveFields(zone); await NAV.DeleteZone(zone, ACD.Default).ConfigureAwait(true); ZoneViewModels.Remove(zvm); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); ErrorText = e.Message; State = ModelState.Error; } finally { State = ModelState.Normal; LoadAnimation = false; } }
public async Task DeleteZone(object obj) { if (NotNetOrConnection) { return; } ZoneViewModel zvm = (ZoneViewModel)obj; //string request = String.Format(AppResources.ZonesPlanViewModel_DeleteZone, zvm.Name); string variant1 = String.Format(AppResources.ZonesPlanViewModel_DeleteZone, zvm.Code); string variant2 = String.Format(AppResources.ZonesPlanViewModel_DeleteZone2, zvm.Code); var action = await App.Current.MainPage.DisplayActionSheet( AppResources.ZonesPlanViewModel_DeleteQuestion, AppResources.ZonesPlanViewModel_DeleteCancel, null, variant1, variant2); if ((action != null) && (action != AppResources.ZonesPlanViewModel_DeleteCancel)) { if (action == variant1) { await zvm.SaveToZoneSchemeVisible(false); } if (action == variant2) { try { State = ModelState.Loading; Zone zone = new Zone(); zvm.SaveFields(zone); await NAV.DeleteZone(zone, ACD.Default).ConfigureAwait(true); ZoneViewModels.Remove(zvm); State = ModelState.Normal; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); ErrorText = e.Message; State = ModelState.Error; } finally { LoadAnimation = false; } } await Load(); } }