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

            if (result)
            {
                IsBusyProgress = true;
                var response = await Task.Run(() =>
                                              ProjectCommonLocationImagesDataStore.DeleteItemAsync(obj)
                                              );

                if (response.Status == ApiResult.Success)
                {
                    IsBusyProgress = false;
                    await LoadData();

                    // await Shell.Current.Navigation.PopAsync();
                }
                //  await ProjectCommonLocationImagesDataStore.DeleteItemAsync(obj);
                // Shell.Current.Navigation.RemovePage(new BuildingLocationDetail());
                await LoadData();

                // await Shell.Current.Navigation.PushAsync(new ProjectDetail() { BindingContext = new ProjectDetailViewModel() { Project = project } });
            }
        }
        public async Task AddNewPhoto(ProjectCommonLocationImages obj)
        {
            await ProjectCommonLocationImagesDataStore.AddItemAsync(obj);

            ProjectCommonLocationImagesItems = new ObservableCollection <ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            // UnitPhotoCount = VisualApartmentLocationPhotoItems.Count.ToString();
        }
        public async Task AddNewPhoto(ProjectCommonLocationImages obj)
        {
            await ProjectCommonLocationImagesDataStore.AddItemAsync(obj);

            //     ProjectCommonLocationImagesDataStore = new ObservableCollection<ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            //  CountItem = ProjectCommonLocationImagesDataStore.Count.ToString();
        }
Пример #4
0
        private async Task Save()
        {
            if (string.IsNullOrEmpty(ProjectCommonLocationImages.Name))
            {
                await Shell.Current.DisplayAlert("Alert", "Project name is required", "OK");

                return;
            }
            if (string.IsNullOrEmpty(ProjectCommonLocationImages.Id))
            {
                ProjectCommonLocationImages.Id = Guid.NewGuid().ToString();

                ProjectCommonLocationImages.ProjectLocationId = ProjectLocation.Id.ToString();
                ////Project.
                ////   Project.ProjectImage = ImgPata;

                await ProjectCommonLocationImagesDataStore.AddItemAsync(ProjectCommonLocationImages);

                await Shell.Current.Navigation.PopAsync();

                // await Shell.Current.Navigation.PushAsync(new ProjectLocationDetail() { BindingContext = new ProjectLocationDetailViewModel() { ProjectLocation = ProjectLocation } });
            }
            else
            {
                await ProjectCommonLocationImagesDataStore.UpdateItemAsync(ProjectCommonLocationImages);

                await Shell.Current.Navigation.PopAsync();
            }
            //await Shell.Current.Navigation.PushAsync(new ProjectLocationDetail() { BindingContext = new ProjectDetailViewModel() { Project = Project } });
        }
        private void GetImageDetail(ImageData ImgData)
        {
            ImageData data = ImgData;
            ProjectCommonLocationImages _locImage = new ProjectCommonLocationImages();

            _locImage.Id                = Guid.NewGuid().ToString();
            _locImage.ImageUrl          = data.Path;
            _locImage.ImageName         = data.Name;
            _locImage.ImageDescription  = data.Description;
            _locImage.ProjectLocationId = ProjectLocation.Id;

            ProjectCommonLocationImagesDataStore.AddItemAsync(_locImage);
            Task.Run(() => this.LoadData()).Wait();
            //LoadData();
        }
Пример #6
0
        public async void Save(byte[] arr)
        {
            IsBusyProgress = true;
            //  var editorPage = obj as ImageEditorPageWithoutDetail;

            //var signaturepad = editorPage.Content.FindByName("signaturepad") as SignaturePadView;
            //signaturepad.ClearLabel.IsVisible = false;

            // var gritoolbar = editorPage.Content.FindByName("gridtoolbar") as Grid;
            //  gritoolbar.IsVisible = false;

            //  var savebutton = editorPage.Content.FindByName("GridOperation") as Grid;
            // savebutton.IsVisible = false;
            //var detailGrid = editorPage.Content.FindByName("detailGrid") as Grid;
            //detailGrid.IsVisible = false;

            // var imgcolors = editorPage.Content.FindByName("imgcolors") as Image;
            //  imgcolors.IsVisible = false;

            // var commentslider = editorPage.Content.FindByName("commentcolorslider") as Slider;
            // commentslider.IsVisible = false;

            // var txtName = editorPage.Content.FindByName("txtName") as BorderlessEntry;
            //  commentslider.IsVisible = false;
            //   var txtDescription = editorPage.Content.FindByName("txtDescription") as XEditor;
            //commentslider.IsVisible = false;

            //var scratchslider = editorPage.Content.FindByName("scratchcolorslider") as Slider;
            //scratchslider.IsVisible = false;


            //  string path = await CrossScreenshot.Current.CaptureAndSaveAsync();
            //byte[] resizedImage = DependencyService.Get<IImageService>().ResizeTheImage(await CrossScreenshot.Current.CaptureAsync(), 2000, 1800);
            string path = await DependencyService.Get <ISaveFile>().SaveFiles(Guid.NewGuid().ToString(), arr);

            // imageData.Path = filepath;
            //     await App.Current.MainPage.Navigation.PopAsync();
            //ImageData d = new ImageData();
            // SelectedImage= imageData.Path = path;
            if (imageData.FormType == "VP")
            {
                VisualProjectLocationPhotoItems[i].ImageUrl = path;
                if (App.IsInvasive == false)
                {
                    await VisualProjectLocationPhotoDataStore.UpdateItemAsync(VisualProjectLocationPhotoItems[i], imageData.IsEditVisual);
                }
                else
                {
                    await InvasiveVisualProjectLocationPhotoDataStore.UpdateItemAsync(VisualProjectLocationPhotoItems[i], imageData.IsEditVisual);
                }
            }
            else if (imageData.FormType == "VB")
            {
                VisualBuildingLocationPhotoItems[i].ImageUrl = path;
                // imageData.VisualBuildingLocationPhoto.Image = path;
                if (App.IsInvasive == false)
                {
                    await VisualBuildingLocationPhotoDataStore.UpdateItemAsync(VisualBuildingLocationPhotoItems[i]);
                }
                else
                {
                    await InvasiveVisualBuildingLocationPhotoDataStore.UpdateItemAsync(VisualBuildingLocationPhotoItems[i]);
                }
            }
            else if (imageData.FormType == "VA")
            {
                string oldp = VisualApartmentLocationPhotoItems[i].ImageUrl;
                VisualApartmentLocationPhotoItems[i].ImageUrl = path;
                if (App.IsInvasive == false)
                {
                    await VisualApartmentLocationPhotoDataStore.UpdateItemAsync(VisualApartmentLocationPhotoItems[i]);
                }
                else
                {
                    await InvasiveVisualApartmentLocationPhotoDataStore.UpdateItemAsync(VisualApartmentLocationPhotoItems[i]);
                }
            }
            if (imageData.FormType == "P")
            {
                ProjectCommonLocationImagesItems[i].ImageUrl = path;
                await ProjectCommonLocationImagesDataStore.UpdateItemAsync(ProjectCommonLocationImagesItems[i]);
            }
            else if (imageData.FormType == "B")
            {
                BuildingCommonLocationImagesItems[i].ImageUrl = path;
                await BuildingCommonLocationImagesDataStore.UpdateItemAsync(BuildingCommonLocationImagesItems[i]);
            }
            else if (imageData.FormType == "A")
            {
                BuildingApartmentImagesItems[i].ImageUrl = path;

                await BuildingApartmentImagesDataStore.UpdateItemAsync(BuildingApartmentImagesItems[i]);
            }

            // signaturepad.Clear();
            //  gritoolbar.IsVisible = true;
            //savebutton.IsVisible = true;
            //commentslider.IsVisible = true;
            //scratchslider.IsVisible = true;
            IsBusyProgress = false;
            // var labelcomment = editorPage.Content.FindByName("labelcomment") as Label;
            //  labelcomment.IsVisible = false;
            //  labelcomment.Text = string.Empty;
            //  VisualProjectLocationPhotoItems = new ObservableCollection<VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualProjectLocationPhoto.VisualID));
            await Next(null);

            // imageData.Name = txtName.Text;
            // imageData.Description = txtDescription.Text;
            //  Callback?.Invoke(imageData);
        }
Пример #7
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);
                    }
                }
            }
        }
Пример #8
0
        public async Task Load()
        {
            if (imageData.FormType == "VP")
            {
                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 = VisualProjectLocationPhotoItems.IndexOf(VisualProjectLocationPhotoItems.Where(c => c.Id == imageData.VisualProjectLocationPhoto.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = VisualProjectLocationPhotoItems[i].ImageUrl;
            }
            else if (imageData.FormType == "VB")
            {
                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 = VisualBuildingLocationPhotoItems.IndexOf(VisualBuildingLocationPhotoItems.Where(c => c.Id == imageData.VisualBuildingLocationPhoto.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = VisualBuildingLocationPhotoItems[i].ImageUrl;
            }
            else if (imageData.FormType == "VA")
            {
                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 = VisualApartmentLocationPhotoItems.IndexOf(VisualApartmentLocationPhotoItems.Where(c => c.Id == imageData.VisualApartmentLocationPhoto.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = VisualApartmentLocationPhotoItems[i].ImageUrl;
            }
            else if (imageData.FormType == "P")
            {
                ProjectCommonLocationImagesItems = new ObservableCollection <ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(imageData.ProjectCommonLocationImages.ProjectLocationId));
                i = ProjectCommonLocationImagesItems.IndexOf(ProjectCommonLocationImagesItems.Where(c => c.Id == imageData.ProjectCommonLocationImages.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = ProjectCommonLocationImagesItems[i].ImageUrl;
            }
            else if (imageData.FormType == "B")
            {
                BuildingCommonLocationImagesItems = new ObservableCollection <BuildingCommonLocationImages>(await BuildingCommonLocationImagesDataStore.GetItemsAsyncByBuildingId(imageData.BuildingCommonLocationImages.BuildingLocationId));
                i = BuildingCommonLocationImagesItems.IndexOf(BuildingCommonLocationImagesItems.Where(c => c.Id == imageData.BuildingCommonLocationImages.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = BuildingCommonLocationImagesItems[i].ImageUrl;
            }
            else if (imageData.FormType == "A")
            {
                BuildingApartmentImagesItems = new ObservableCollection <BuildingApartmentImages>(await BuildingApartmentImagesDataStore.GetItemsAsyncByApartmentID(imageData.BuildingApartmentImages.BuildingApartmentId));
                i = BuildingApartmentImagesItems.IndexOf(BuildingApartmentImagesItems.Where(c => c.Id == imageData.BuildingApartmentImages.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = BuildingApartmentImagesItems[i].ImageUrl;
            }
        }
        public async Task <bool> UploadGallary(List <string> images)
        {
            IsBusyProgress = true;
            bool result = HttpUtil.UploadFromGallary(ProjectLocation.Name, "/api/ProjectLocationImage/AddEdit?ParentId=" + ProjectLocation.Id + "&UserId=" + App.LogUser.Id.ToString(), images);

            if (result == true)
            {
                IsBusyProgress = false;
            }
            ProjectCommonLocationImagesItems = new ObservableCollection <ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            return(await Task.FromResult(true));
        }
 private async void GetImageProjectCommonLocationImages(ImageData ImgData)
 {
     ProjectCommonLocationImages.ImageUrl = ImgData.Path;
     await ProjectCommonLocationImagesDataStore.UpdateItemAsync(ProjectCommonLocationImages);
 }