Exemple #1
0
 public AddPlotViewModel(INavigation navigation)
 {
     _navigation     = navigation;
     _plotValidator  = new PlotValidator();
     _plot           = new PLOT();
     _plotRepository = new PlotRepository();
     AddCommand      = new Command(async() => await AddPlot(""));
     ViewAllCommand  = new Command(async() => await ShowList());
     ListFMU         = PickerService.ForestItems().OrderBy(c => c.NAME).ToList();
 }
        public AddPlotViewModel(INavigation navigation, string fk)
        {
            _navigation        = navigation;
            _plotValidator     = new PlotValidator();
            _plot              = new PLOT();
            _plotRepository    = new PlotRepository();
            _selectedprojectid = fk;
            Utils util = new Utils();

            //Do defaults
            _plot.VSNPLOTNAME             = "VSN";
            _plot.IsDeleted               = "N";
            _plot.DATUM                   = "NAD83";
            _plot.PROJECTID               = fk;
            _plot.ACCESSCONDITIONCODE     = 1;
            _plot.PLOTOVERVIEWDATE        = System.DateTime.Now;
            _plot.MEASUREYEAR             = _plot.PLOTOVERVIEWDATE.Year;
            _plot.CANOPYSTRUCTURECODE1    = "S";
            _plot.MATURITYCLASSCODE1      = "S";
            _plot.MATURITYCLASSRATIONALE1 = "Dominant cohort has achieved crown closure";
            _plot.FOLLOWUPREQUIRED        = "N";



            if (util.UseDefaultDeclination)
            {
                _plot.DECLINATION = util.DefaultDeclination;
            }

            AddCommand          = new Command(async() => await AddPlot(_selectedprojectid));
            ViewAllCommand      = new Command(async() => await ShowList());
            ListFMU             = PickerService.ForestItems().OrderBy(c => c.NAME).ToList();
            ListSpecies         = PickerService.SpeciesItems().OrderBy(c => c.NAME).ToList();
            ListMeasurementType = PickerService.MeasurementTypeItems().OrderBy(c => c.NAME).ToList();
            ListNonStandardType = PickerService.NonStandardTypeItems().OrderBy(c => c.NAME).ToList();
            //   ListPerson = FillPersonPicker().OrderBy(c => c.NAME).ToList();
            ListPerson            = PickerService.FillPersonPicker(_plotRepository.GetPersonList(_selectedprojectid)).OrderBy(c => c.NAME).ToList();
            ListGrowthPlot        = PickerService.GrowthPlotItems().OrderBy(c => c.NAME).ToList();
            ListGrowthPlotType    = PickerService.GrowthPlotTypeItems().OrderBy(c => c.NAME).ToList();
            ListAccessCondition   = PickerService.AccessConditionItems().OrderBy(c => c.NAME).ToList();
            CommentsCommand       = new Command(async() => await ShowComments());
            StandInfoCommand      = new Command(async() => await ShowStandInfo());
            ForestHealthCommand   = new Command(async() => await ShowForestHealth());
            PlotCrewCommand       = new Command(async() => await ShowPlotCrew());
            PhotoCommand          = new Command(async() => await ShowPhoto());
            OnAppearingCommand    = new Command(() => OnAppearing());
            OnDisappearingCommand = new Command(() => OnDisappearing());
            LocationCommand       = new Command(async() => await DoLocation());
        }
        private async Task <bool> TrySave()
        {
            PlotValidator    _validator        = new PlotValidator();
            ValidationResult validationResults = _validator.Validate(_plot);

            if (validationResults.IsValid)
            {
                _ = AddPlot(_selectedprojectid);
                return(true);
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Update Plot", validationResults.Errors[0].ErrorMessage, "Ok");

                return(false);
            }
        }
Exemple #4
0
        public AddPlotViewModel(INavigation navigation, string fk)
        {
            _navigation         = navigation;
            _plotValidator      = new PlotValidator();
            _plot               = new PLOT();
            _plotRepository     = new PlotRepository();
            _selectedprojectid  = fk;
            AddCommand          = new Command(async() => await AddPlot(_selectedprojectid));
            ViewAllCommand      = new Command(async() => await ShowList());
            ListFMU             = PickerService.ForestItems().OrderBy(c => c.NAME).ToList();
            ListSpecies         = PickerService.SpeciesItems().OrderBy(c => c.NAME).ToList();
            ListCanopyOrigin    = PickerService.CanopyOriginItems().OrderBy(c => c.NAME).ToList();
            ListCanopyStructure = PickerService.CanopyStructureItems().OrderBy(c => c.NAME).ToList();
            ListMaturityClass   = PickerService.MaturityClassItems().OrderBy(c => c.NAME).ToList();

            CommentsCommand = new Command(async() => await ShowComments());
        }
        async Task UpdatePlot()
        {
            //  var validationResults = _projectValidator.Validate(_project);
            PlotValidator    _plotValidator    = new PlotValidator();
            ValidationResult validationResults = _plotValidator.Validate(_plot);

            if (validationResults.IsValid)
            {
                bool isUserAccept = await Application.Current.MainPage.DisplayAlert("Plot Details", "Update Plot Details", "OK", "Cancel");

                if (isUserAccept)
                {
                    _plot.LastModified = System.DateTime.UtcNow;
                    _plotRepository.UpdatePlot(_plot);
                    await _navigation.PopAsync();
                }
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Add Plot", validationResults.Errors[0].ErrorMessage, "Ok");
            }
        }
        private async Task GoBack()
        {
            // display Alert for confirmation
            if (IsChanged)
            {
                PlotValidator _validator     = new PlotValidator();
                PlotValidator _fullvalidator = new PlotValidator(true);

                ValidationResult validationResults     = _validator.Validate(_plot);
                ValidationResult fullvalidationResults = _fullvalidator.Validate(_plot);

                ParseValidater _parser = new ParseValidater();
                (_plot.ERRORCOUNT, _plot.ERRORMSG) = _parser.Parse(fullvalidationResults);


//                PlotValidator _validator = new PlotValidator();
//              ValidationResult validationResults = _validator.Validate(_plot);
                if (validationResults.IsValid)
                {
                    _ = AddPlot(_selectedprojectid);
                    Shell.Current.Navigating -= Current_Navigating;
                    //      await Shell.Current.GoToAsync("..", true);
                    await _navigation.PopAsync(true);
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Update Plot", validationResults.Errors[0].ErrorMessage, "Ok");
                }
            }
            else
            {
                Shell.Current.Navigating -= Current_Navigating;
                //       await Shell.Current.GoToAsync("..", true);
                await _navigation.PopAsync(true);
            }
        }