public Seed[] GetSeeds(Seed.SeedTypes type, int catalogId) { var args = new DynamicParameters(); args.Add(nameof(Seed.SeedType), type, DbType.Int32, ParameterDirection.Input); args.Add(nameof(Seed.CatalogId), catalogId, DbType.Int32, ParameterDirection.Input); using (var connection = new SqlConnection(_connectionString)) { try { connection.Open(); var results = connection.ExecuteReader(GET_SEEDS_PROC, args, commandType: CommandType.StoredProcedure); var seeds = results.Parse <Seed>().ToArray(); // Recursively Pull in Parent Seeds and attach them to children foreach (var seed in seeds) { seed.ParentSeeds.AddRange(this.GetParentSeeds((int)seed.SeedId, connection)); } return(seeds.ToArray()); } catch (Exception ex) { Logging.Logger.Instance.Log(Logging.Logger.Severity.Error, $"Exception executing: {GET_SEEDS_PROC} {ex}"); return(null); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } } }
/// <summary> /// Set the active seed type in the current seed catalog /// </summary> /// <param name="seedType"></param> public void SetActiveSeedType(Seed.SeedTypes seedType) { this._activeSeedType = seedType; this.ActiveSeedTypeUpdated?.Invoke(); }
/// <summary> /// Gets the specific seed from the seed store /// </summary> /// <param name="type"></param> /// <param name="catalogId"></param> /// <param name="traits"></param> /// <returns></returns> public Seed GetSeed(Seed.SeedTypes type, int catalogId, string traits) { return(_seeds[catalogId].Values.FirstOrDefault(a => a.SeedType == type && a.Traits == traits)); }
public Seed GetSeed(Seed.SeedTypes type, int catalogId, string traits) { throw new NotImplementedException(); // TODO: Implement this in the database if we need it }
/// <summary> /// Gets all seeds from the seed store of the specified type in the specified catalog /// </summary> /// <param name="type"></param> /// <param name="catalogId"></param> /// <returns></returns> public Seed[] GetSeeds(Seed.SeedTypes type, int catalogId) { return(!_seeds.ContainsKey(catalogId) ? new Seed[0] : _seeds[catalogId].Values.Where(a => a.SeedType == type).ToArray()); }