Exemple #1
0
        public async Task Load()
        {
            if (imageData.FormType == "VP")
            {
                if (App.IsInvasive == false)
                {
                    VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualProjectLocationPhoto.VisualLocationId, false));
                }
                else
                {
                    VisualProjectLocationPhotoItems = new ObservableCollection <VisualProjectLocationPhoto>(await InvasiveVisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualProjectLocationPhoto.VisualLocationId, false));
                }

                i = VisualProjectLocationPhotoItems.IndexOf(VisualProjectLocationPhotoItems.Where(c => c.Id == imageData.VisualProjectLocationPhoto.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = VisualProjectLocationPhotoItems[i].ImageUrl;
            }
            else if (imageData.FormType == "VB")
            {
                if (App.IsInvasive == false)
                {
                    VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await VisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualBuildingLocationPhoto.VisualBuildingId, false));
                }
                else
                {
                    VisualBuildingLocationPhotoItems = new ObservableCollection <VisualBuildingLocationPhoto>(await InvasiveVisualBuildingLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualBuildingLocationPhoto.VisualBuildingId, false));
                }


                i = VisualBuildingLocationPhotoItems.IndexOf(VisualBuildingLocationPhotoItems.Where(c => c.Id == imageData.VisualBuildingLocationPhoto.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = VisualBuildingLocationPhotoItems[i].ImageUrl;
            }
            else if (imageData.FormType == "VA")
            {
                if (App.IsInvasive == false)
                {
                    VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualApartmentLocationPhoto.VisualApartmentId, false));
                }
                else
                {
                    VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(imageData.VisualApartmentLocationPhoto.VisualApartmentId, false));
                }
                i = VisualApartmentLocationPhotoItems.IndexOf(VisualApartmentLocationPhotoItems.Where(c => c.Id == imageData.VisualApartmentLocationPhoto.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = VisualApartmentLocationPhotoItems[i].ImageUrl;
            }
            else if (imageData.FormType == "P")
            {
                ProjectCommonLocationImagesItems = new ObservableCollection <ProjectCommonLocationImages>(await ProjectCommonLocationImagesDataStore.GetItemsAsyncByProjectLocationId(imageData.ProjectCommonLocationImages.ProjectLocationId));
                i = ProjectCommonLocationImagesItems.IndexOf(ProjectCommonLocationImagesItems.Where(c => c.Id == imageData.ProjectCommonLocationImages.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = ProjectCommonLocationImagesItems[i].ImageUrl;
            }
            else if (imageData.FormType == "B")
            {
                BuildingCommonLocationImagesItems = new ObservableCollection <BuildingCommonLocationImages>(await BuildingCommonLocationImagesDataStore.GetItemsAsyncByBuildingId(imageData.BuildingCommonLocationImages.BuildingLocationId));
                i = BuildingCommonLocationImagesItems.IndexOf(BuildingCommonLocationImagesItems.Where(c => c.Id == imageData.BuildingCommonLocationImages.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = BuildingCommonLocationImagesItems[i].ImageUrl;
            }
            else if (imageData.FormType == "A")
            {
                BuildingApartmentImagesItems = new ObservableCollection <BuildingApartmentImages>(await BuildingApartmentImagesDataStore.GetItemsAsyncByApartmentID(imageData.BuildingApartmentImages.BuildingApartmentId));
                i = BuildingApartmentImagesItems.IndexOf(BuildingApartmentImagesItems.Where(c => c.Id == imageData.BuildingApartmentImages.Id).Single());
                //imageData.VisualProjectLocationPhoto = VisualProjectLocationPhotoItems[i];
                SelectedImage = BuildingApartmentImagesItems[i].ImageUrl;
            }
        }
Exemple #2
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));
        }