Example #1
0
        public void Create(Bullet bullet)
        {
            using (var connection = SqlConnectionFactory.GetConnection())
            using (var command = connection.CreateCommand())
            {
                command.CommandType = CommandType.Text;
                command.CommandText = SqlScripts.Bullet_Create;
                AddParameters(bullet, command);

                connection.Open();
                bullet.Id = (int)command.ExecuteScalar();
            }
        }
Example #2
0
        public void Import(Bullet bullet)
        {
            using (var connection = SqlConnectionFactory.GetConnection())
            using (var command = connection.CreateCommand())
            {
                command.CommandType = CommandType.Text;
                command.CommandText = SqlScripts.Bullet_Import;
                AddParameters(bullet, command);
                command.Parameters.Add(new SqlParameter("@id", bullet.Id));

                connection.Open();
                command.ExecuteNonQuery();
            }
        }
Example #3
0
        public Bullet CreateBullet(int id = 0, int pageId = 0)
        {
            var result = new Bullet
            {
                Id = id,
                Text = string.Format("Unit test bullet text - {0}.", _bulletCount),
                HorizontalOffset = 20,
                VerticalOffset = 20,
                OffsetElementId = "TestBulletOffsetElementId",
                Number = 1,
                PageId = pageId,
            };

            _bulletCount++;

            return result;
        }
Example #4
0
 private static void AddParameters(Bullet bullet, SqlCommand command)
 {
     command.Parameters.AddRange(new SqlParameter[] {
                 new SqlParameter("@pageId", bullet.PageId),
                 new SqlParameter("@number", bullet.Number),
                 new SqlParameter("@text", bullet.Text),
                 new SqlParameter("@verticalOffset", bullet.VerticalOffset),
                 new SqlParameter("@horizontalOffset", bullet.HorizontalOffset),
                 new SqlParameter("@offsetElementId", bullet.OffsetElementId),
             });
 }