public async Task AddNewPhoto(BuildingCommonLocationImages obj) { await BuildingCommonLocationImagesDataStore.AddItemAsync(obj); // ProjectCommonLocationImagesDataStore = new ObservableCollection<ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id)); // CountItem = ProjectCommonLocationImagesDataStore.Count.ToString(); }
public async Task <Response> DeleteItemAsync(BuildingCommonLocationImages item) { item.UserId = App.LogUser.Id.ToString(); 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/BuildingLocationImage/DeleteBuildingLocationImage", 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)); } } }
private async Task DeleteImagCommandExecute(BuildingCommonLocationImages 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(() => BuildingCommonLocationImagesDataStore.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 } }); } }
public async Task AddNewPhoto(BuildingCommonLocationImages obj) { await BuildingCommonLocationImagesDataStore.AddItemAsync(obj); BuildingCommonLocationImages = new ObservableCollection <BuildingCommonLocationImages>(await BuildingCommonLocationImagesDataStore.GetItemsAsyncByBuildingId(BuildingLocation.Id)); // UnitPhotoCount = VisualApartmentLocationPhotoItems.Count.ToString(); }
async Task ExecuteImageDetailCommand(BuildingCommonLocationImages parm) { BuildingCommonLocationImage = parm; ImgData.Path = parm.ImageUrl; ImgData.BuildingCommonLocationImages = parm; ImgData.FormType = "B"; await CurrentWithoutDetail.EditImage(ImgData, GetImageFromEditor); // await Shell.Current.Navigation.PushAsync(new EditBuildingLocationImage() { BindingContext = new EditBuildingLocationImageViewModel() { Title = "Edit Building Common Location Image", BuildingCommonLocationImages = parm, BuildingLocation = BuildingLocation } }); // await App.Current.MainPage.Navigation.PushModalAsync(new ShowImage() { BindingContext = new ShowImageViewModel(parm.Image,parm.Name,parm.Description,parm.CreatedOn) }); }
public async Task <bool> UpdateItemAsync(BuildingCommonLocationImages item) { Regex UrlMatch = new Regex(@"^(http|https)://", RegexOptions.Singleline); // 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("BuildingLocation", item.ImageUrl, "/api/BuildingLocationImage/AddEdit?ParentId=" + item.BuildingLocationId + "&UserId=" + App.LogUser.Id.ToString() + "&Id=" + item.Id).Result; return(await Task.FromResult(true)); }
private void GetImageDetail(ImageData ImgData) { ImageData data = ImgData; BuildingCommonLocationImages _locImage = new BuildingCommonLocationImages(); _locImage.Id = Guid.NewGuid().ToString(); _locImage.ImageUrl = data.Path; _locImage.ImageName = data.Name; _locImage.ImageDescription = data.Description; _locImage.BuildingLocationId = buildingLocation.Id; BuildingCommonLocationImagesDataStore.AddItemAsync(_locImage); Task.Run(() => this.LoadData()).Wait(); // LoadData(); //ImgPatah = ImgData.Path; // await App.Current.MainPage.DisplayAlert(ImgData.Name, ImgData.Path, "ok", "cancel"); }
public async Task <bool> AddItemAsync(BuildingCommonLocationImages item) { items.Add(item); return(await Task.FromResult(true)); }
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"; }