public async Task AddNewPhoto(BuildingApartmentImages obj)
        {
            await BuildingApartmentImagesDataStore.AddItemAsync(obj);

            //     ProjectCommonLocationImagesDataStore = new ObservableCollection<ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            //  CountItem = ProjectCommonLocationImagesDataStore.Count.ToString();
        }
Ejemplo n.º 2
0
        public async Task <Response> DeleteItemAsync(BuildingApartmentImages item)
        {
            item.IsDelete = true;
            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/BuildingApartmentImage/DeleteBuildingApartmentImage", item))
                {
                    var responseBody = await response.Content.ReadAsStringAsync();

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

                    response.EnsureSuccessStatusCode();
                    //if (response.IsSuccessStatusCode == false)
                    //{
                    //    throw new ApiException
                    //    {
                    //        StatusCode = (int)response.StatusCode,
                    //        Content = result.Message
                    //    };
                    //}
                    return(await Task.FromResult(result));
                }
            }
        }
Ejemplo n.º 3
0
        public async Task AddNewPhoto(BuildingApartmentImages obj)
        {
            await BuildingApartmentImagesDataStore.AddItemAsync(obj);

            BuildingApartmentImages = new ObservableCollection <BuildingApartmentImages>(await BuildingApartmentImagesDataStore.GetItemsAsyncByApartmentID(BuildingApartment.Id));
            // UnitPhotoCount = VisualApartmentLocationPhotoItems.Count.ToString();
        }
Ejemplo n.º 4
0
        private async Task DeleteImagCommandExecute(BuildingApartmentImages 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(() =>
                                              BuildingApartmentImagesDataStore.DeleteItemAsync(obj)
                                              );

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

                // Shell.Current.Navigation.RemovePage(new BuildingLocationDetail());

                // await Shell.Current.Navigation.PushAsync(new ProjectDetail() { BindingContext = new ProjectDetailViewModel() { Project = project } });
            }
        }
Ejemplo n.º 5
0
        private void GetImageDetail(ImageData ImgData)
        {
            ImageData data = ImgData;
            BuildingApartmentImages _locImage = new BuildingApartmentImages();

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

            BuildingApartmentImagesDataStore.AddItemAsync(_locImage);

            Task.Run(() => this.LoadData()).Wait();
        }
Ejemplo n.º 6
0
        public async Task <bool> UpdateItemAsync(BuildingApartmentImages item)
        {
            //var oldItem = items.Where((BuildingApartmentImages arg) => arg.Id == item.Id).FirstOrDefault();
            //items.Remove(oldItem);
            //items.Add(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("Apartment", item.ImageUrl, "/api/BuildingApartmentImage/AddEdit?ParentId=" + item.BuildingApartmentId + "&UserId=" + App.LogUser.Id.ToString() + "&Id=" + item.Id).Result;

            return(await Task.FromResult(true));
        }
Ejemplo n.º 7
0
        async Task ExecuteImageDetailCommand(BuildingApartmentImages parm)
        {
            BuildingApartmentImage = parm;
            ImgData.Path           = parm.ImageUrl;

            ImgData.BuildingApartmentImages = parm;
            ImgData.FormType = "A";
            await CurrentWithoutDetail.EditImage(ImgData, GetImageFromEditor);

            // await Shell.Current.Navigation.PushAsync(new EditBuildingApartmentImage() { BindingContext = new EditBuildingApartmentImageViewModel() { Title = "Edit Building Apartment Image", BuildingApartmentImages = parm, BuildingApartment = BuildingApartment } });

            // ShellNavigationState state = Shell.Current.CurrentState;
            //    await App.Current.MainPage.Navigation.PushModalAsync(new ShowImage() { BindingContext = new ShowImageViewModel(parm.Image,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.º 8
0
        public async Task <bool> AddItemAsync(BuildingApartmentImages item)
        {
            items.Add(item);

            return(await Task.FromResult(true));
        }
Ejemplo n.º 9
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";
        }