Пример #1
0
 /// <summary>
 /// Updates the fish in the database
 /// </summary>
 /// <param name="item">The item to update</param>
 /// <returns>True if successfull, false if not</returns>
 /// <exception cref="Exceptions.CreatureNotFound">Thrown if fish is not found</exception>
 public bool UpdateFish(FishClass item)
 {
     throw new NotImplementedException();
 }
Пример #2
0
        /// <summary>
        /// Reads a list of creature items from database
        /// </summary>
        /// <param name="search">The search pattern</param>
        /// <returns>A list of Creatures. Empty list if no Creatures was found</returns>
        public List<Creatures> Read(BasicSearch search)
        {
            List<Creatures> theList = new List<Creatures>();

            using (MySqlConnection conn = getAConnection())
            {
                if (conn.State != System.Data.ConnectionState.Open)
                {
                    using (MySqlCommand cmd = new MySqlCommand(SELECT_CREATURE, conn))
                    {
                        cmd.CommandText = SELECT_CREATURE + search.GetWhereClause();
                        try
                        {
                            using (MySqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    Creatures item = null;
                                    CreatureTypes ct = (CreatureTypes)reader.GetInt32("creatuteType");
                                    switch(ct)
                                    {
                                        case CreatureTypes.Crustacean:
                                            item = new CrustaceanClass();

                                            break;
                                        case CreatureTypes.Fish:
                                            item = new FishClass();
                                            break;
                                        case CreatureTypes.Gastropoda:
                                            item = new GastropodaClass();
                                            break;
                                        case CreatureTypes.Plant:
                                            item = new PlantClass();
                                            break;
                                        case CreatureTypes.Reptile:
                                            item = new ReptileClass();
                                            break;
                                    }
                                    if (item != null)
                                    {
                                        //CreatureIdentification
                                        item.CurrentVersion = reader.GetDecimal("currentVersion");
                                        item.Description.Danish = reader.GetString("danishDescription");
                                        item.Description.English = reader.GetString("englishDescription");
                                        item.Description.German = reader.GetString("germanDescription");
                                        item.ID = reader.GetInt32("id");
                                        item.ScientificName = this.ReadLatinName(reader.GetInt32("scientificNameId"));
                                        item.Tradenames.Danish = reader.GetString("danishTradenames");
                                        item.Tradenames.English = reader.GetString("englishTradenames");
                                        item.Tradenames.German = reader.GetString("germanTradenames");
                                        //Creatures
                                        item.AquaLogCode = reader.GetString("aqualogCode");
                                        item.CreatedByUser = reader.GetString("createdUser");
                                        item.CreatedDateTime = reader.GetDateTime("createdDateTime");
                                        item.DataSource = (EnumDataSource)reader.GetInt32("dataSource");
                                        item.Family = this.ReadFamily(reader.GetInt32("familyId"));
                                        item.Group = this.ReadGroup(reader.GetInt32("groupTypeId"));
                                        item.Hardness.MaxValue = reader.GetDecimal("maxHardness");
                                        item.Hardness.MinValue = reader.GetDecimal("minHardness");
                                        item.Light.MaxLight = (EnumLight)reader.GetInt32("maxLight");
                                        item.Light.MinLight = (EnumLight)reader.GetInt32("minLight");
                                        item.OtherLiterature = this.ReadBook(item, BookListType.Other);
                                        item.PH.MaxValue = reader.GetDecimal("maxPh");
                                        item.PH.MinValue = reader.GetDecimal("minPh");
                                        item.Pictures = this.ReadPicture(item);
                                        item.Protected = this.ReadProtection(reader.GetInt32("protected"));
                                        item.ReferenceBooks = this.ReadBook(item, BookListType.Reference);
                                        item.Region = this.ReadRegion(reader.GetInt32("regionId"));
                                        //item.Synonyms = this.reads // Missing from IDatabase
                                        if (item is Animal)
                                        {
                                            //
                                        }
                                        theList.Add(item);
                                    }
                                }
                            }
                        }
                        catch (SqlException ex)
                        {
                            handleDBError(new Delegates.DatabaseArgs(ex));
                        }
                    }
                }
                else
                {
                    handleDBError(new Delegates.DatabaseArgs("Connection not open"));
                }
            }
            return theList;
        }
Пример #3
0
        private void setValuesOnFishcmd(MySqlCommand cmd, FishClass item)
        {
            setValuesFromCreatureIdentification(cmd, item);
            setValuesFromCreature(cmd, item);
            setValuesFromAnimal(cmd, item);

            cmd.Parameters.AddWithValue("fishBaseId", item.FishBaseId);
            if (item.SwimmingPosition.ID == 0)
            {
                item.SwimmingPosition = this.CreateSwimmingPosition(item.SwimmingPosition);
            }
            cmd.Parameters.AddWithValue("swimmingPositionId", item.SwimmingPosition.ID);
            cmd.Parameters.AddWithValue("tankWidth", item.TankWidth);
        }
Пример #4
0
 /// <summary>
 /// Delete the fish in the database
 /// </summary>
 /// <param name="item">The item to delete</param>
 /// <returns>True if successfull, false if not</returns>
 /// <exception cref="Exceptions.CreatureNotFound">Thrown if fish is not found</exception>
 public bool DeleteFish(FishClass item)
 {
     return deleteCreature(item);
 }
Пример #5
0
 /// <summary>
 /// Create the item in the database
 /// </summary>
 /// <param name="item">The item to create</param>
 /// <returns>The updated item with database id</returns>
 /// <exception cref="Exceptions.CreatureAlreadyExists">Thrown if item already exists</exception>
 public FishClass CreateFish(FishClass item)
 {
     item.ID = createCreature(item);
     return item;
 }