Пример #1
0
        public static PlantSpeciesInfo GetPlantSpeciesInfo(int platnSpeciesId)
        {
            PlantSpecies plantSpecies = GetPlantSpecies(platnSpeciesId);

            PlantSpeciesInfo plantSpeciesInfo = new PlantSpeciesInfo {
                id        = plantSpecies.id,
                name      = plantSpecies.name,
                varieties = GetVarietiesForPlant(plantSpecies.id)
            };

            return(plantSpeciesInfo);
        }
Пример #2
0
        private static List <PlantSpecies> GetPlantSpecies(string query)
        {
            List <PlantSpecies> plantSpecies = new List <PlantSpecies>();

            foreach (var plantSpec in pgSqlSingleManager.ExecuteSQL(query))
            {
                PlantSpecies newPlantSpec = new PlantSpecies {
                    id   = Int32.Parse(plantSpec["id"]),
                    name = plantSpec["name"]
                };
                plantSpecies.Add(newPlantSpec);
            }

            return(plantSpecies);
        }
Пример #3
0
        public static PlantSpecies AddPlantSpecies(string name)
        {
            pgSqlSingleManager.ExecuteSQL($"insert into cultivation.plant_species (name) values ('{name}')");
            var plantResult = pgSqlSingleManager.ExecuteSQL($"select * from cultivation.plant_species where name = '{name}'");

            string addPlantQuery = $"insert into cultivation.plants (plant_species) " +
                                   $"values ({Int32.Parse(plantResult[0]["id"])})";

            pgSqlSingleManager.ExecuteSQL(addPlantQuery);

            PlantSpecies newPlant = new PlantSpecies {
                id   = Int32.Parse(plantResult[0]["id"]),
                name = plantResult[0]["name"]
            };

            return(newPlant);
        }
Пример #4
0
        private static List <Plant> GetPlants(string query)
        {
            List <Plant> plants = new List <Plant>();

            foreach (var plant in pgSqlSingleManager.ExecuteSQL(query))
            {
                Plant newPlant = new Plant {
                    id           = Int32.Parse(plant["id"]),
                    plantSpecies = PlantSpecies.GetPlantSpecies(Int32.Parse(plant["plant_species"]))
                };

                try {
                    newPlant.variety = Variety.GetVariety(Int32.Parse(plant["plant_variety"]));
                } catch { }

                plants.Add(newPlant);
            }

            return(plants);
        }