private async Task DeleteVisualFormCommandExecute(ProjectLocation_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(() =>
                                              VisualFormProjectLocationDataStore.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 <bool> Running()
        {
            ProjectLocation = await ProjectLocationDataStore.GetItemAsync(ProjectLocation.Id);

            // ProjectCommonLocationImagesItems = new ObservableCollection<ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            if (App.LogUser.RoleName == "Admin")
            {
                IsEditDeleteAccess = true;
            }
            else if (ProjectLocation.UserId == App.LogUser.Id.ToString())
            {
                IsEditDeleteAccess = true;
            }
            if (App.IsInvasive)
            {
                IsInvasiveControlDisable = true;
                IsEditDeleteAccess       = false;
            }
            VisualFormProjectLocationItems = new ObservableCollection <ProjectLocation_Visual>(await VisualFormProjectLocationDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));

            return(await Task.FromResult(true));
        }
Esempio n. 3
0
        private async Task <Response> SaveLoad()
        {
            Response response = new Response();

            try
            {
                string errorMessage = string.Empty;
                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))
                {
                    response.Message = errorMessage;
                    response.Status  = ApiResult.Fail;

                    // await Shell.Current.DisplayAlert("Validation Error", errorMessage, "OK");
                }
                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 VisualFormProjectLocationDataStore.GetItemAsync(VisualForm.Id) == null)
                    {
                        List <string> list = VisualProjectLocationPhotoItems.Select(c => c.ImageUrl).ToList();
                        response = await VisualFormProjectLocationDataStore.AddItemAsync(VisualForm, list);

                        // VisualProjectLocationPhotoItems.Clear();
                    }
                    else
                    {
                        List <MultiImage> finelList = new List <MultiImage>();
                        if (App.IsInvasive == false)
                        {
                            response = await VisualFormProjectLocationDataStore.UpdateItemAsync(VisualForm, App.VisualEditTracking);
                        }
                        else
                        {
                            if (InvasiveVisualProjectLocationPhotoItems.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 VisualFormProjectLocationDataStore.UpdateItemAsync(VisualForm, App.VisualEditTrackingForInvasive);
                            }
                        }


                        // VisualProjectLocationPhotoItems.Clear();
                    }
                }
            }

            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Status  = ApiResult.Fail;
            }
            return(await Task.FromResult(response));
        }