private async Task DeleteVisualFormCommandExecute(BuildingLocation_Visual 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(() => VisualFormBuildingLocationDataStore.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 } }); } }
private async Task <Response> SaveLoad() { Response response = new Response(); string errorMessage = string.Empty; try { if (string.IsNullOrEmpty(VisualForm.Name)) { errorMessage += "\nName is required\n"; } if (string.IsNullOrEmpty(UnitPhotoCount) || UnitPhotoCount == "0") { errorMessage += "\nUnit photo required\n"; } if (ExteriorElements.Count == 0) { errorMessage += "\nExterior Elements photo required\n"; } if (WaterProofingElements.Count == 0) { errorMessage += "\nWaterProofing Elements required\n"; } if (RadioList_VisualReviewItems.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nVisual Review required\n"; } if (RadioList_AnyVisualSignItems.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nAny visual signs of leaksrequired\n"; } if (RadioList_FurtherInasiveItems.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nFurther Invasive Review Required Yes/No required\n"; } if (RadioList_ConditionAssessment.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nCondition Assessment Required Yes/No required\n"; } if (RadioList_LifeExpectancyEEE.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nLife Expectancy Exterior Elevated Elements (EEE) required\n"; } if (RadioList_LifeExpectancyLBC.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nLife Expectancy Load Bearing Componenets (LBC) required\n"; } if (RadioList_LifeExpectancyAWE.Where(c => c.IsChecked).Any() == false) { errorMessage += "\nLife Expectancy Associated Waterproofing Elements (AWE) required\n"; } if (!string.IsNullOrEmpty(errorMessage)) { // await Shell.Current.DisplayAlert("Validation Error", errorMessage, "OK"); response.Message = errorMessage; response.Status = ApiResult.Fail; // return await Task.FromResult(response); } else { // VisualForm.CreatedOn = DateTime.Now.ToString("dd-MMM-yyy hh:mm:ss"); VisualForm.ExteriorElements = string.Join(",", ExteriorElements.ToArray()); VisualForm.WaterProofingElements = string.Join(",", WaterProofingElements.ToArray()); VisualForm.VisualReview = RadioList_VisualReviewItems.Where(c => c.IsChecked == true).Single().Name; VisualForm.AnyVisualSign = RadioList_AnyVisualSignItems.Where(c => c.IsChecked == true).Single().Name; VisualForm.FurtherInasive = RadioList_FurtherInasiveItems.Where(c => c.IsChecked == true).Single().Name; VisualForm.ConditionAssessment = RadioList_ConditionAssessment.Where(c => c.IsChecked == true).Single().Name; VisualForm.LifeExpectancyEEE = RadioList_LifeExpectancyEEE.Where(c => c.IsChecked == true).Single().Name; VisualForm.LifeExpectancyLBC = RadioList_LifeExpectancyLBC.Where(c => c.IsChecked == true).Single().Name; VisualForm.LifeExpectancyAWE = RadioList_LifeExpectancyAWE.Where(c => c.IsChecked == true).Single().Name; if (await VisualFormBuildingLocationDataStore.GetItemAsync(VisualForm.Id) == null) { List <string> list = VisualBuildingLocationPhotoItems.Select(c => c.ImageUrl).ToList(); response = await VisualFormBuildingLocationDataStore.AddItemAsync(VisualForm, list); // return await Task.FromResult(response); } else { List <MultiImage> finelList = new List <MultiImage>(); if (App.IsInvasive == false) { response = await VisualFormBuildingLocationDataStore.UpdateItemAsync(VisualForm, App.VisualEditTracking); } else { if (InvasiveVisualBuildingLocationPhotoItems.Count == 0) { errorMessage += "\nInvasive photo required\n";; } if (string.IsNullOrEmpty(visualForm.ImageDescription)) { errorMessage += "\nDescription required\n";; } if (!string.IsNullOrEmpty(errorMessage)) { response.Message = errorMessage; response.Status = ApiResult.Fail; // await Shell.Current.DisplayAlert("Validation Error", errorMessage, "OK"); } else { response = await VisualFormBuildingLocationDataStore.UpdateItemAsync(VisualForm, App.VisualEditTrackingForInvasive); } } // return await Task.FromResult(response); // await VisualFormBuildingLocationDataStore.UpdateItemAsync(VisualForm); } // await Shell.Current.Navigation.PopAsync(); } } catch (Exception ex) { response.Message = ex.Message; response.Status = ApiResult.Fail; } return(await Task.FromResult(response)); }
private async Task <bool> Running() { if (BuildingLocation != null) { BuildingLocation = await BuildingLocationDataStore.GetItemAsync(BuildingLocation.Id).ConfigureAwait(true); // BuildingCommonLocationImages = new ObservableCollection<BuildingCommonLocationImages>(await BuildingCommonLocationImagesDataStore.GetItemsAsyncByBuildingId(BuildingLocation.Id)); VisualFormBuildingLocationItems = new ObservableCollection <BuildingLocation_Visual>(await VisualFormBuildingLocationDataStore.GetItemsAsyncByBuildingLocationId(BuildingLocation.Id)); if (App.LogUser.RoleName == "Admin") { IsEditDeleteAccess = true; } else if (BuildingLocation.UserId == App.LogUser.Id.ToString()) { IsEditDeleteAccess = true; } if (App.IsInvasive) { IsInvasiveControlDisable = true; IsEditDeleteAccess = false; } } return(await Task.FromResult(true)); }