コード例 #1
0
        //geschreven door owen, aangepast door robin en christophe voor mvvm en later services
        public void fillComboBoxSoort(TfgsvGeslacht selectedGeslacht, ObservableCollection <TfgsvSoort> cmbSoortCollection)
        {
            var list = Enumerable.Empty <TfgsvSoort>().AsQueryable();

            //use the GeslachtId, selected in the combobox to filter the list and load the remaining plant Soort in the Soort combobox
            // checking if selected Soort is selected to prevent null exception
            if (selectedGeslacht != null)
            {
                // Requesting te list of Soort
                list = _dao.fillTfgsvSoort(Convert.ToInt32(selectedGeslacht.GeslachtId));
            }
            else
            {
                // Requesting te list of Soort  with 0 because there is noting selected in the combobox of type.
                list = _dao.fillTfgsvSoort(0);
            }

            // clearing te content of te combobox of Soort
            cmbSoortCollection.Clear();
            // a list to add type that have been added to the combobox. this is used for preventing two of the same type in the combo box
            var ControleList = new List <string>();

            //adding or list to the combobox
            foreach (var item in list)
            {
                if (!ControleList.Contains(item.Soortnaam))
                {
                    cmbSoortCollection.Add(item);
                    ControleList.Add(item.Soortnaam);
                }
            }
        }
コード例 #2
0
        public void LoadGeslachten()
        {
            //Senne, Maarten, Hermes
            var geslachten = _geslachten;

            TfgsvGeslacht.Clear();
            foreach (var tfgsvGeslacht in geslachten.OrderBy(p => p.Geslachtnaam))
            {
                TfgsvGeslacht.Add(tfgsvGeslacht);
            }
        }
コード例 #3
0
        public void ClearFilters()
        {
            _selectedType     = null;
            _selectedFamilie  = null;
            _selectedGeslacht = null;
            _selectedSoort    = null;
            _selectedVariant  = null;

            PlantResults.Clear();

            //Alle waardes naar default zetten
            InitializeTfgsv();
            LoadAll();
        }
コード例 #4
0
        public string EditPlantData(long plantId, Fenotype fenotype, List <FenotypeMulti> fenotypeMulti, Abiotiek abiotiek,
                                    List <AbiotiekMulti> abiotiekMulti,
                                    List <Commensalisme> commensalisme, List <CommSocialbiliteit> commSocialbiliteit, List <CommLevensvorm> commLevensvorm, ExtraEigenschap extraEigenschap,
                                    TfgsvType type, TfgsvFamilie familie, TfgsvGeslacht geslacht,
                                    TfgsvSoort soort, TfgsvVariant variant, string plantDichtheidMin, string plantDichtheidMax)
        {
            string result = "Plant werd aangepast";

            try
            {
                //fenotype
                var dbFenotype = context.Fenotype.FirstOrDefault(f => f.PlantId == fenotype.PlantId);
                dbFenotype = fenotype;

                //abiotiek
                var dbAbiotiek = context.Abiotiek.FirstOrDefault(a => a.PlantId == abiotiek.PlantId);
                dbAbiotiek = abiotiek;

                context.AbiotiekMulti.RemoveRange(GetAbiotiekMulti(plantId));
                context.AbiotiekMulti.AddRange(abiotiekMulti);
                //commensalisme
                context.Commensalisme.RemoveRange(GetCommStrategieFromPlant(plantId));
                context.Commensalisme.AddRange(commensalisme);

                var dbSocial = context.CommensalismeMulti.Where(c => c.Eigenschap == "Sociabiliteit");
                var dbLeven  = context.CommensalismeMulti.Where(c => c.Eigenschap == "Levensvorm");

                context.CommensalismeMulti.RemoveRange(dbSocial.Where(c => c.PlantId == plantId));
                context.CommensalismeMulti.RemoveRange(dbLeven.Where(c => c.PlantId == plantId));

                foreach (var socialbiliteit in commSocialbiliteit)
                {
                    context.CommensalismeMulti.Add(new CommensalismeMulti()
                    {
                        PlantId = plantId, Eigenschap = "Sociabiliteit", Waarde = socialbiliteit.Sociabiliteit
                    });
                }

                foreach (var levensvorm in commLevensvorm)
                {
                    context.CommensalismeMulti.Add(new CommensalismeMulti()
                    {
                        PlantId = plantId, Eigenschap = "Levensvorm", Waarde = levensvorm.Levensvorm
                    });
                }
                //extra eigenschappen
                var dbExtra = context.ExtraEigenschap.FirstOrDefault(e => e.PlantId == extraEigenschap.PlantId);
                dbExtra = extraEigenschap;

                //plant
                var dbPlant = GetPlantWithId(plantId);
                dbPlant.Type     = type.Planttypenaam;
                dbPlant.Familie  = familie.Familienaam;
                dbPlant.Geslacht = geslacht.Geslachtnaam;
                dbPlant.Soort    = soort.Soortnaam;
                dbPlant.Variant  = variant.Variantnaam;

                string fgsv = familie.Familienaam + " " + geslacht.Geslachtnaam;
                if (soort.Soortnaam != null)
                {
                    fgsv += " " + soort.Soortnaam;
                }

                if (variant.Variantnaam != null)
                {
                    fgsv += " " + variant.Variantnaam;
                }
                dbPlant.Fgsv = fgsv;

                if (plantDichtheidMin == String.Empty)
                {
                    dbPlant.PlantdichtheidMin = null;
                }
                else
                {
                    dbPlant.PlantdichtheidMin = short.Parse(plantDichtheidMin);
                }
                if (plantDichtheidMax == String.Empty)
                {
                    dbPlant.PlantdichtheidMax = null;
                }
                else
                {
                    dbPlant.PlantdichtheidMax = short.Parse(plantDichtheidMax);
                }

                dbPlant.TypeId    = (int?)type.Planttypeid;
                dbPlant.FamilieId = (int?)familie.FamileId;
                if (soort.Soortid == 0)
                {
                    dbPlant.SoortId = null;
                }
                else
                {
                    dbPlant.SoortId = (int?)soort.Soortid;
                }

                if (variant.VariantId == 0)
                {
                    dbPlant.VariantId = null;
                }
                else
                {
                    dbPlant.VariantId = (int?)variant.VariantId;
                }

                context.FenotypeMulti.AddRange(fenotypeMulti);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                result = e + "\nEr is een fout opgetreden tijdens het opslaan, gelieve contact op te nemen met de beheerders van Plantify";
            }

            return(result);
        }
コード例 #5
0
        //Geschreven door Owen op basis van de eerste Search van Kenny.
        //Christophe & Owen: gedeeltelijke omzetting naar mvvm
        //Omgezet naar service door kenny
        public List <Plant> ApplyFilter(TfgsvType SelectedtType, TfgsvFamilie SelectedFamilie, TfgsvGeslacht SelectedGeslacht, TfgsvSoort SelectedSoort, TfgsvVariant SelectedVariant, string SelectedNederlandseNaam, string SelectedRatioBloeiBlad)
        {
            var listPlants = _dao.getAllPlants();

            if (SelectedtType != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.TypeId != SelectedtType.Planttypeid)
                    {
                        listPlants.Remove(item);
                    }
                }
            }
            if (SelectedFamilie != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.FamilieId != SelectedFamilie.FamileId)
                    {
                        listPlants.Remove(item);
                    }
                }
            }
            if (SelectedGeslacht != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.GeslachtId != SelectedGeslacht.GeslachtId)
                    {
                        listPlants.Remove(item);
                    }
                }
            }
            if (SelectedSoort != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.SoortId != SelectedSoort.Soortid)
                    {
                        listPlants.Remove(item);
                    }
                }
            }
            if (SelectedVariant != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.VariantId != null)
                    {
                        if (item.VariantId != SelectedVariant.VariantId)
                        {
                            listPlants.Remove(item);
                        }
                    }
                    else if (item.VariantId == null)
                    {
                        listPlants.Remove(item);
                    }
                }
            }

            if (SelectedNederlandseNaam != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.NederlandsNaam != null)
                    {
                        if (!item.NederlandsNaam.Contains(SelectedNederlandseNaam))
                        {
                            listPlants.Remove(item);
                        }
                    }
                    else if (item.NederlandsNaam == null)
                    {
                        listPlants.Remove(item);
                    }
                }
            }

            if (SelectedRatioBloeiBlad != null)
            {
                foreach (var item in listPlants.ToList())
                {
                    if (item.Fenotype.Count != 0)
                    {
                        foreach (var itemFenotype in item.Fenotype)
                        {
                            if (itemFenotype.RatioBloeiBlad != null || itemFenotype.RatioBloeiBlad != String.Empty)
                            {
                                if (itemFenotype.RatioBloeiBlad != SelectedRatioBloeiBlad)
                                {
                                    listPlants.Remove(item);
                                }
                            }
                            else
                            {
                                listPlants.Remove(item);
                            }
                        }
                    }
                    else
                    {
                        listPlants.Remove(item);
                    }
                }
            }
            return(listPlants);
        }