public List <CivilizationDAL> CivilizationsGetAll(int Skip, int Take)
        {
            List <CivilizationDAL> proposedReturnValue = new List <CivilizationDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("CivilizationsGetAll", _con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", Skip);
                    command.Parameters.AddWithValue("@take", Take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        CivilizationMapper cm = new CivilizationMapper(reader);
                        while (reader.Read())
                        {
                            CivilizationDAL item = cm.ToCivilization(reader);
                            proposedReturnValue.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
                // stays empty
            }
            return(proposedReturnValue);
        }
        public CivilizationDAL CivilizationFindByID(int CivID)
        {
            CivilizationDAL proposedreturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("CivilizationFindByID", _con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@CivID", CivID);     //QuotesQuotesQuotes
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        CivilizationMapper cm = new CivilizationMapper(reader);
                        int count             = 0;
                        while (reader.Read())
                        {
                            proposedreturnValue = cm.ToCivilization(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"Multiple Civilizations found for ID {CivID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
                // stays empty
            }
            return(proposedreturnValue);
        }
Exemplo n.º 3
0
        public CivilizationDAL ToCivilization(SqlDataReader reader)
        {
            CivilizationDAL proposedReturnValue = new CivilizationDAL();

            proposedReturnValue.CivID    = reader.GetInt32(OffsetToCivID);
            proposedReturnValue.CivName  = reader.GetString(OffsetToCivName);
            proposedReturnValue.CivStart = reader.GetDateTime(OffsetToCivStart);
            proposedReturnValue.CivEnd   = reader.GetDateTime(OffsetToCivEnd);
            return(proposedReturnValue);
        }