private async Task DeleteImageCommandCommandExecute(VisualBuildingLocationPhoto parm)
        {
            var result = await Shell.Current.DisplayAlert(
                "Alert",
                "Are you sure you want to remove?",
                "Yes", "No");



            if (result)
            {
                VisualBuildingLocationPhoto obj = parm as VisualBuildingLocationPhoto;
                await InvasiveVisualBuildingLocationPhotoDataStore.DeleteItemAsync(obj);

                InvasiveVisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await InvasiveVisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));
                InvasiveUnitPhotoCount = InvasiveVisualBuildingLocationPhotoItems.Count.ToString();
            }
        }
Exemple #2
0
        private async Task Delete(object obj)
        {
            var editorPage = obj as ImageEditorPageWithoutDetail;
            var result     = await Shell.Current.DisplayAlert(
                "Alert",
                "Are you sure you want to remove?",
                "Yes", "No");

            if (result)
            {
                if (imageData.FormType == "VP")
                {
                    if (App.IsInvasive == false)
                    {
                        await VisualProjectLocationPhotoDataStore.DeleteItemAsync(VisualProjectLocationPhotoItems[i], imageData.IsEditVisual);
                    }
                    else
                    {
                        await InvasiveVisualProjectLocationPhotoDataStore.DeleteItemAsync(VisualProjectLocationPhotoItems[i], imageData.IsEditVisual);
                    }

                    if (App.IsInvasive == false)
                    {
                        VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualProjectLocationPhoto.VisualLocationId, false));
                    }
                    else
                    {
                        VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await InvasiveVisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualProjectLocationPhoto.VisualLocationId, false));
                    }
                    i--;
                    int Count = VisualProjectLocationPhotoItems.Count;
                    if (Count == 0)
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                    if (Count == 1)
                    {
                        i = 1;
                        await Prv(obj);
                    }


                    if (i == Count - 1)
                    {
                        //i = 0;
                        await Prv(obj);
                    }
                    else
                    {
                        await Next(obj);
                    }
                    //int Count = new ObservableCollection<VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualProjectLocationPhoto.VisualID)).Count;
                    //if (Count != 0)
                    //    await Next(obj);
                    //else
                    //    await App.Current.MainPage.Navigation.PopAsync();
                }
                else if (imageData.FormType == "VB")
                {
                    if (App.IsInvasive == false)
                    {
                        await VisualBuildingLocationPhotoDataStore.DeleteItemAsync(VisualBuildingLocationPhotoItems[i]);
                    }
                    else
                    {
                        await InvasiveVisualBuildingLocationPhotoDataStore.DeleteItemAsync(VisualBuildingLocationPhotoItems[i]);
                    }


                    if (App.IsInvasive == false)
                    {
                        VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualBuildingLocationPhoto.VisualBuildingId, false));
                    }
                    else
                    {
                        VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await InvasiveVisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualBuildingLocationPhoto.VisualBuildingId, false));
                    }
                    i--;

                    //int Count = new ObservableCollection<VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualBuildingLocationPhoto.VisualID)).Count;
                    //if (Count != 0)
                    //    await Next(obj);
                    //else
                    //    await App.Current.MainPage.Navigation.PopAsync();
                    int Count = VisualBuildingLocationPhotoItems.Count;
                    if (Count == 0)
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                    if (Count == 1)
                    {
                        i = 1;
                        await Prv(obj);
                    }


                    if (i == Count - 1)
                    {
                        await Prv(obj);
                    }

                    else
                    {
                        await Next(obj);
                    }
                }
                else if (imageData.FormType == "VA")
                {
                    if (App.IsInvasive == false)
                    {
                        await VisualApartmentLocationPhotoDataStore.DeleteItemAsync(VisualApartmentLocationPhotoItems[i]);
                    }
                    else
                    {
                        await InvasiveVisualApartmentLocationPhotoDataStore.DeleteItemAsync(VisualApartmentLocationPhotoItems[i]);
                    }
                    if (App.IsInvasive == false)
                    {
                        VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualApartmentLocationPhoto.VisualApartmentId, false));
                    }
                    else
                    {
                        VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualApartmentLocationPhoto.VisualApartmentId, false));
                    }

                    i--;
                    int Count = VisualApartmentLocationPhotoItems.Count;
                    if (Count == 0)
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                    if (Count == 1)
                    {
                        i = 1;
                        await Prv(obj);
                    }


                    if (i == Count - 1)
                    {
                        await Prv(obj);
                    }

                    else
                    {
                        await Next(obj);
                    }
                    //int Count = new ObservableCollection<VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualApartmentLocationPhoto.VisualID)).Count;
                    //if (Count != 0)
                    //    await Next(obj);
                    //else
                    //    await App.Current.MainPage.Navigation.PopAsync();
                }
                if (imageData.FormType == "P")
                {
                    await ProjectCommonLocationImagesDataStore.DeleteItemAsync(ProjectCommonLocationImagesItems[i]);

                    ProjectCommonLocationImagesItems = new ObservableCollection <ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(imageData.ProjectCommonLocationImages.ProjectLocationId));
                    i--;
                    int Count = ProjectCommonLocationImagesItems.Count;
                    if (Count == 0)
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                    if (Count == 1)
                    {
                        i = 1;
                        await Prv(obj);
                    }


                    if (i == Count - 1)
                    {
                        await Prv(obj);
                    }

                    else
                    {
                        await Next(obj);
                    }
                    //int Count = new ObservableCollection<ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(imageData.ProjectCommonLocationImages.ProjectLocationId)).Count;
                    //if (Count != 0)
                    //    await Next(obj);
                    //else
                    //    await App.Current.MainPage.Navigation.PopAsync();
                }
                else if (imageData.FormType == "B")
                {
                    await BuildingCommonLocationImagesDataStore.DeleteItemAsync(BuildingCommonLocationImagesItems[i]);

                    BuildingCommonLocationImagesItems = new ObservableCollection <BuildingCommonLocationImages>(await BuildingCommonLocationImagesDataStore.GetItemsAsyncByBuildingId(imageData.BuildingCommonLocationImages.BuildingLocationId));
                    i--;
                    //    int Count = new ObservableCollection<BuildingCommonLocationImages>(await BuildingCommonLocationImagesDataStore.GetItemsAsyncByBuildingId(imageData.BuildingCommonLocationImages.BuildingId)).Count;
                    //    if (Count != 0)
                    //        await Next(obj);
                    //    else
                    //        await App.Current.MainPage.Navigation.PopAsync();
                    int Count = BuildingCommonLocationImagesItems.Count;
                    if (Count == 0)
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                    if (Count == 1)
                    {
                        i = 1;
                        await Prv(obj);
                    }


                    if (i == Count - 1)
                    {
                        await Prv(obj);
                    }

                    else
                    {
                        await Next(obj);
                    }
                }
                else if (imageData.FormType == "A")
                {
                    await BuildingApartmentImagesDataStore.DeleteItemAsync(BuildingApartmentImagesItems[i]);

                    BuildingApartmentImagesItems = new ObservableCollection <BuildingApartmentImages>(await BuildingApartmentImagesDataStore.GetItemsAsyncByApartmentID(imageData.BuildingApartmentImages.BuildingApartmentId));
                    i--;
                    //int Count = new ObservableCollection<BuildingApartmentImages>(await BuildingApartmentImagesDataStore.GetItemsAsyncByApartmentID(imageData.BuildingApartmentImages.ApartmentID)).Count;
                    //if (Count != 0)
                    //    await Next(obj);
                    //else
                    //    await App.Current.MainPage.Navigation.PopAsync();
                    int Count = BuildingApartmentImagesItems.Count;
                    if (Count == 0)
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                    if (Count == 1)
                    {
                        i = 1;
                        await Prv(obj);
                    }


                    if (i == Count - 1)
                    {
                        await Prv(obj);
                    }

                    else
                    {
                        await Next(obj);
                    }
                }
            }
        }