public async Task DeleteLocation(object obj)
        {
            if (NotNetOrConnection)
            {
                return;
            }

            try
            {
                LocationViewModel lvm = (LocationViewModel)obj;
                State = ModelState.Loading;
                await NAV.DeleteLocation(lvm.Code, ACD.Default).ConfigureAwait(true);

                LocationViewModels.Remove(lvm);
                State = ModelState.Normal;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                ErrorText = e.Message;
                State     = ModelState.Error;
            }
            finally
            {
                LoadAnimation = false;
            }
        }
Exemplo n.º 2
0
        public async Task DeleteLocation(object obj)
        {
            if (NotNetOrConnection)
            {
                return;
            }

            LocationViewModel lvm = (LocationViewModel)obj;

            string variant1 = String.Format(AppResources.LocationsPlanViewModel_DeleteLocation, lvm.Code);
            string variant2 = String.Format(AppResources.LocationsPlanViewModel_DeleteLocation2, lvm.Code);

            var action = await App.Current.MainPage.DisplayActionSheet(
                AppResources.LocationsPlanViewModel_DeleteQuestion,
                AppResources.LocationsPlanViewModel_DeleteCancel,
                null,
                variant1,
                variant2);

            if ((action != null) && (action != AppResources.LocationsPlanViewModel_DeleteCancel))
            {
                if (action == variant1)
                {
                    await lvm.SaveToLocationSchemeVisible(false);
                }
                if (action == variant2)
                {
                    try
                    {
                        LoadAnimation = true;
                        State         = ModelState.Loading;
                        await NAV.DeleteLocation(lvm.Code, ACD.Default).ConfigureAwait(true);

                        LocationViewModels.Remove(lvm);
                        State = ModelState.Normal;
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        ErrorText = e.Message;
                        State     = ModelState.Error;
                    }
                    finally
                    {
                        LoadAnimation = false;
                    }
                }
                await Load();
            }
        }