public void Create(GenericKeyValueModel genericKeyValueModel)
        {
            GenericKeyValues.Add(genericKeyValueModel);
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = $"INSERT INTO {_tableName} (name)" +
                              "VALUES(@name)";
            cmd.Parameters.AddWithValue("@name", genericKeyValueModel.Name);
            DatabaseManager.connector.NonQuery(cmd);
        }
        public void Update(GenericKeyValueModel genericKeyValueModel)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = $"UPDATE {_tableName} SET name=@name" +
                              $" WHERE{_tableName}.id = @id";
            cmd.Parameters.AddWithValue("@id", genericKeyValueModel.Id);
            cmd.Parameters.AddWithValue("@name", genericKeyValueModel.Name);
            DatabaseManager.connector.NonQuery(cmd);
        }
        public void Delete(GenericKeyValueModel genericKeyValueModel)
        {
            GenericKeyValues.Remove(genericKeyValueModel);
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = $"DELETE FROM {_tableName}" +
                              $" WHERE {_tableName}.id = @id";
            cmd.Parameters.AddWithValue("@id", genericKeyValueModel.Id);
            DatabaseManager.connector.NonQuery(cmd);
            //todo: what if genericKeyValueModel doesnt exist?
        }
        public List <GenericKeyValueModel> GetAll()
        {
            GenericKeyValues = new List <GenericKeyValueModel>();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "Select * " +
                              $"FROM {_tableName}";
            using (DatabaseManager.connector)
            {
                DatabaseManager.connector.Open();
                using (DbDataReader reader = DatabaseManager.connector.Query(cmd))
                {
                    while (reader.Read())
                    {
                        GenericKeyValueModel genericKeyValueModel = new GenericKeyValueModel();
                        genericKeyValueModel.Id   = reader.GetInt32(0);
                        genericKeyValueModel.Name = reader.GetString(1);
                        GenericKeyValues.Add(genericKeyValueModel);
                    }
                }
            }
            return(GenericKeyValues);
        }
 public void Update(GenericKeyValueModel genericKeyValueModel)
 {
 }
 public void Create(GenericKeyValueModel genericKeyValueModel)
 {
     GenericKeyValues.Add(genericKeyValueModel);
 }
 public void Delete(GenericKeyValueModel genericKeyValueModel)
 {
     GenericKeyValues.Remove(genericKeyValueModel);
 }