public ProjectScreenBeforeViewModal(int ID, bool isback = false)
        {
            _isback = isback;
            tblSystemElement _tblSystemElement = new tblSystemElement();

            SystemElementList = _tblSystemElement.GetAll();
            SESelectedValue   = 1;
            tblMaterial _tblMaterial = new tblMaterial();

            MaterialList = _tblMaterial.GetAll();

            if (isback == false)
            {
                _LocationID = ID;
            }
            else
            {
                Building    build   = new Building();
                tblBuilding dbbuild = new tblBuilding();
                build       = dbbuild.Get(ID);
                _LocationID = build.LocationID;

                //build.BuildingSystemID = BSSelectedValue;
                SESelectedValue = 1;
                //build.SystemTypeID = STSelectedValue;
                //build.Rating = RTSelectedValue;
                _detail = build.Details;
                //build.IsDeficiencyRepair = true;
                //build.ProjectID = 0;
                //build.ServiceContractID = 0;
                //build.WorkOrder = "";
                //build.Compliance = "";
                _height          = build.Height;
                _width           = build.Width;
                MATSelectedValue = build.MaterialID;
                //build.UserID = Constant.UserID;
                //build.createon = DateTime.Now;
                //build.AddressLine1 = "";
                //build.AddressLine2 = "";
                //build.LocationCity = "";
                //build.StateID = 0;
                //build.LocationZip = "";
                //build.createon = DateTime.Now;
                //build.isedit = false;
                //build.issupload = false;
            }
        }
        private async Task SaveDetail()
        {
            //data save
            LocationPhoto lp = new LocationPhoto();

            lp.createon  = DateTime.Now;
            lp.issupload = false;
            lp.isedit    = false;

            //byte[] imageBytes = streamToByteArray(_imgstream);
            //StreamReader sr = new StreamReader(_imgstream);


            string str = "";

            str = Convert.ToBase64String(_imgstream);

            lp.Photo = str;
            //await App.Current.MainPage.DisplayAlert("Upload Image", str, "Yes", "No");
            //lp.Photo = System.Convert.FromBase64String(_imageSource);
            lp.PhotoDescription           = _pagename;
            lp.PhotoUploadedDate          = DateTime.Now;
            lp.LocationID                 = 0;
            lp.BuildingID                 = 0;
            lp.BuildingDeficiencyRepairID = 0;
            lp.buildingWorkOrderID        = 0;
            lp.WorkOrderFollowUpID        = 0;
            if (_pagename == "Location")
            {
                lp.LocationID = _id;
            }
            else if (_pagename == "FCA")
            {
                lp.BuildingID = _id;
            }
            else if (_pagename == "BuildingDeficiencyRepair")
            {
                lp.BuildingDeficiencyRepairID = _id;
            }
            else if (_pagename == "Facility")
            {
                lp.FacilityID = _id;
            }
            else if (_pagename == "WorkOrder")
            {
                lp.WorkOrderRequestID = _id;
            }
            else if (_pagename == "WorkOrderFollowUp")
            {
                lp.WorkOrderFollowUpID = _id;
            }
            else if (_pagename == "ProjectScreenBefore")
            {
                lp.ProjectBeforeID = _id;
            }
            else if (_pagename == "BuildingDeficiencyRepairScreen")
            {
                lp.DeficiencyRepairID = _id;
            }
            //else if (_pagename == "WorkOrderFollowUp")
            //{
            //    lp.WorkOrderFollowUpID = _id;
            //}
            //else if (_pagename == "WorkOrderFollowUp")
            //{
            //    lp.WorkOrderFollowUpID = _id;
            //}

            tblLocationPhoto dblp = new tblLocationPhoto();

            dblp.Add(lp);
            bool ans = await App.Current.MainPage.DisplayAlert("Upload Image", "Would you like to Upload another Image?", "Yes", "No");

            if (ans == true)
            {
                App.Current.MainPage = new MainPageCS(new CameraPage(_id, _pagename));
            }
            else if (ans == false)
            {
                //App.Current.MainPage = new MainPageCS(new LocationView());
                //redirection
                if (_pagename == "Location")
                {
                    Location    loc   = new Location();
                    tblLocation dbloc = new tblLocation();
                    loc = dbloc.Get(_id);
                    //await App.Current.MainPage.DisplayAlert("Selected Location", _id.ToString(), "Submit");
                    //tblJobType dbjobtype = new tblJobType();
                    //JobType jt = new JobType();
                    //jt = dbjobtype.Get(loc.JobTypeID);
                    if (loc.JobTypeID == 1)
                    {
                        if (loc.JobStatusID == 1)
                        {
                            App.Current.MainPage = new MainPageCS(new ProjectScreenBefore(_id, false));
                        }
                        else if (loc.JobStatusID == 2)
                        {
                            //App.Current.MainPage = new MainPageCS(new ProjectScreenActive(_id));
                        }
                        else if (loc.JobStatusID == 3)
                        {
                            //App.Current.MainPage = new MainPageCS(new ProjectScreenAfter(_id));
                        }
                    }
                    else if (loc.JobTypeID == 3)
                    {
                        App.Current.MainPage = new MainPageCS(new FCASystem(_id));
                    }
                    else if (loc.JobTypeID == 4)
                    {
                        App.Current.MainPage = new MainPageCS(new FacilityScreen(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new LocationView());
                    }
                }
                else if (_pagename == "FCA")
                {
                    Building    build   = new Building();
                    tblBuilding DBbuild = new tblBuilding();
                    build = DBbuild.Get(_id);
                    if (build.IsDeficiencyRepair == true)
                    {
                        App.Current.MainPage = new MainPageCS(new FCADeficiencyScreen(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new LocationView());
                    }
                }
                else if (_pagename == "BuildingDeficiencyRepair")
                {
                    App.Current.MainPage = new MainPageCS(new LocationView());
                }
                else if (_pagename == "Facility")
                {
                    tblBuilding DBBuild = new tblBuilding();
                    Building    build   = new Building();
                    build = DBBuild.Get(_id);
                    if (build.WorkOrder != "")
                    {
                        App.Current.MainPage = new MainPageCS(new WorkOrderRequest(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new LocationView());
                    }
                }
                else if (_pagename == "WorkOrder")
                {
                    App.Current.MainPage = new MainPageCS(new WorkOrderFollowUpScreen(_id));
                }
                else if (_pagename == "ProjectScreenBefore")
                {
                    Building    build   = new Building();
                    tblBuilding DBbuild = new tblBuilding();
                    build = DBbuild.Get(_id);
                    bool isDetail = await App.Current.MainPage.DisplayAlert("Detail's", "Do you want add more detail ?", "Yes", "No");

                    if (build.IsDeficiencyRepair == true)
                    {
                        App.Current.MainPage = new MainPageCS(new ProposalChecklistFlatRoof(_id));
                    }
                    else
                    {
                        App.Current.MainPage = new MainPageCS(new DeficiencyRepairScreen(_id));
                    }
                }
                else if (_pagename == "ProjectScreenBefore")
                {
                }
                else
                {
                    App.Current.MainPage = new MainPageCS(new LocationView());
                }
            }
        }