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



            if (result)
            {
                //if (parm.GetType() == typeof(VisualProjectLocationPhoto))
                //{
                VisualApartmentLocationPhoto obj = parm as VisualApartmentLocationPhoto;
                await InvasiveVisualApartmentLocationPhotoDataStore.DeleteItemAsync(obj);

                //InvasiveVisualApartmentLocationPhotoItems = new ObservableCollection<VisualApartmentLocationPhoto>(await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id, false));
                //InvasiveUnitPhotoCount = InvasiveVisualApartmentLocationPhotoItems.Count.ToString();
                //}
                //if (parm.GetType() == typeof(VisualBuildingLocationPhoto))
                //{
                //    VisualBuildingLocationPhoto obj = parm as VisualBuildingLocationPhoto;
                //    await VisualBuildingLocationPhotoDataStore.DeleteItemAsync(obj);

                //}
                //if (parm.GetType() == typeof(VisualApartmentLocationPhoto))
                //{
                //    VisualApartmentLocationPhoto obj = parm as VisualApartmentLocationPhoto;
                //    await VisualApartmentLocationPhotoDataStore.DeleteItemAsync(obj);

                //}
                await Load();
            }
        }
Esempio n. 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);
                    }
                }
            }
        }