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);

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

            ProjectCommonLocationImagesItems = new ObservableCollection <ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            // UnitPhotoCount = VisualApartmentLocationPhotoItems.Count.ToString();
        }
Ejemplo n.º 4
0
        public async Task <bool> UpdateItemAsync(ProjectCommonLocationImages item)
        {
            Regex UrlMatch = new Regex(@"(?i)(http(s)?:\/\/)?(\w{2,25}\.)+\w{3}([a-z0-9\-?=$-_.+!*()]+)(?i)", RegexOptions.Singleline);

            if (item.ImageUrl == "blank.png" || UrlMatch.IsMatch(item.ImageUrl))
            {
                item.ImageUrl = null;
                return(await Task.FromResult(true));
            }
            Response result = HttpUtil.Update_Image("Location", item.ImageUrl, "/api/ProjectLocationImage/AddEdit?ParentId=" + item.ProjectLocationId + "&UserId=" + App.LogUser.Id.ToString() + "&Id=" + item.Id).Result;

            return(await Task.FromResult(true));
        }
        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();
        }
        async Task ExecuteImageDetailCommand(ProjectCommonLocationImages parm)
        {
            ProjectCommonLocationImages = parm;
            ImgData.Path = parm.ImageUrl;
            ImgData.ProjectCommonLocationImages = parm;
            ImgData.FormType = "P";
            await CurrentWithoutDetail.EditImage(ImgData, GetImageProjectCommonLocationImages);

            // await Shell.Current.Navigation.PushAsync(new EditProjectLocationImage() { BindingContext = new EditProjectLocationImageViewModel() { Title = "New Project Common Location", ProjectCommonLocationImages = parm , ProjectLocation = ProjectLocation } });
            // await Shell.Current.Navigation.PushModalAsync(new EditProjectLocationImage() { BindingContext = new EditProjectLocationImageViewModel() { Title = "New Project Common Location", ProjectCommonLocationImages = parm } });
            //await Shell.Current.Navigation.PushAsync(new AddProjectLocation()
            //{
            //    BindingContext = new ProjectLocationAddEditViewModel()
            //    { Title = "New Project Common Location", ProjectLocation = new ProjectLocation() { LocationImage = "blank.png" }, Project = Project }
            //});
            // ShellNavigationState state = Shell.Current.CurrentState;
            //     await Shell.Current.Navigation.PushModalAsync(new ShowImage() { BindingContext = new ShowImageViewModel(parm.ImageUrl, parm.Name,parm.Description,parm.CreatedOn) });
            //await App.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new ProjectDetail() ));

            //  await Application.Current.MainPage.DisplayAlert("Selected Peron", project.ProjectName, "Ok", "cancel");
            // await Shell.Current.GoToAsync("projectdetail");
        }
Ejemplo n.º 7
0
        public async Task <Response> DeleteItemAsync(ProjectCommonLocationImages item)
        {
            item.IsDelete = true;
            item.UserId   = App.LogUser.Id.ToString();
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(App.AzureBackendUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                using (HttpResponseMessage response = await client.PostAsJsonAsync($"api/ProjectLocationImage/DeleteProjectLocationImage", item))
                {
                    var responseBody = await response.Content.ReadAsStringAsync();

                    Response result = JsonConvert.DeserializeObject <Response>(responseBody);

                    response.EnsureSuccessStatusCode();

                    return(await Task.FromResult(result));
                }
            }
        }
Ejemplo n.º 8
0
        private async void OnPictureFinished()
        {
            // ImageSource temp = CameraPreview.ImageSource;
            CameraViewModel vm = (CameraViewModel)this.BindingContext;

            // await DisplayAlert("Confirm", "Picture Taken", "", "Ok");
            //string filepath = await DependencyService.Get<ISaveFile>().SaveFiles(Guid.NewGuid().ToString(), CameraPreview.byteArr);
            //img1.Source = filepath;
            //list.Add(filepath);
            //  detailGrid.IsVisible = false;
            string filepath = await CrossScreenshot.Current.CaptureAndSaveAsync();

            if (vm.IsVisualProjectLocatoion)
            {
                VisualProjectLocationPhoto obj = new VisualProjectLocationPhoto()
                {
                    Image = filepath, Id = Guid.NewGuid().ToString(), VisualID = vm.ProjectLocation_Visual.Id
                };
                await vm.AddNewPhoto(obj);
            }
            if (vm.IsVisualBuilding)
            {
                VisualBuildingLocationPhoto obj = new VisualBuildingLocationPhoto()
                {
                    Image = filepath, Id = Guid.NewGuid().ToString(), VisualID = vm.BuildingLocation_Visual.Id
                };
                await vm.AddNewPhoto(obj);
            }
            if (vm.IsVisualApartment)
            {
                VisualApartmentLocationPhoto obj = new VisualApartmentLocationPhoto()
                {
                    Image = filepath, Id = Guid.NewGuid().ToString(), VisualID = vm.Apartment_Visual.Id
                };
                await vm.AddNewPhoto(obj);
            }
            if (vm.IsProjectLocation)
            {
                ProjectCommonLocationImages obj = new ProjectCommonLocationImages()
                {
                    ImageUrl = filepath, Id = Guid.NewGuid().ToString(), ProjectLocationId = vm.ProjectLocation.Id
                };
                await vm.AddNewPhoto(obj);
            }
            if (vm.IsBuildingLocation)
            {
                BuildingCommonLocationImages obj = new BuildingCommonLocationImages()
                {
                    Image = filepath, Id = Guid.NewGuid().ToString(), BuildingId = vm.BuildingLocation.Id
                };
                await vm.AddNewPhoto(obj);
            }
            if (vm.IsApartment)
            {
                BuildingApartmentImages obj = new BuildingApartmentImages()
                {
                    Image = filepath, Id = Guid.NewGuid().ToString(), ApartmentID = vm.BuildingApartment.Id
                };
                await vm.AddNewPhoto(obj);
            }
            detailGrid.IsVisible = true;
            img1.Source          = filepath;
            // countSelect.Text = list.Count + " Photo Taken";
        }
Ejemplo n.º 9
0
        public async Task <bool> AddItemAsync(ProjectCommonLocationImages item)
        {
            items.Add(item);

            return(await Task.FromResult(true));
        }