Ejemplo n.º 1
0
        public bool InsertMonsterType(Models.MonsterType monsterType)
        {
            var n     = new SqlParameter("name", monsterType.Name);
            var query = "insert into Monster.MonsterType(TypeName, Active) values (@name, 1)";

            return(InsertData(query, n) == 1);
        }
Ejemplo n.º 2
0
        public bool DeleteMonsterType(Models.MonsterType monsterType)
        {
            var query = "delete Monster.MonsterType where MonsterTypeId = @id";
            var id    = new SqlParameter("id", monsterType.MonsterTypeId);
            int result;

            using (var connection = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand(query, connection);

                connection.Open();
                cmd.Parameters.Add(id);
                result = cmd.ExecuteNonQuery();
            }

            return(result >= 0);
        }
Ejemplo n.º 3
0
        public bool UpdateMonsterType(Models.MonsterType monsterType)
        {
            var query  = "update Monster.MonsterType set TypeName = @name, Active = @active where MonsterTypeId = @id";
            var name   = new SqlParameter("name", monsterType.Name);
            var active = new SqlParameter("active", monsterType.Active ? 1 : 0);
            var id     = new SqlParameter("id", monsterType.MonsterTypeId);
            int result;

            using (var connection = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand(query, connection);

                connection.Open();
                cmd.Parameters.AddRange(new SqlParameter[] { id, name, active });
                result = cmd.ExecuteNonQuery();
            }

            return(result >= 0);
        }
 public AdoDataTests()
 {
     gender = new Models.Gender()
     {
         Name = "TestGender"
     };
     monsterType = new Models.MonsterType()
     {
         Name = "TestType"
     };
     title = new Models.Title()
     {
         Name = "TestType"
     };
     monster = new Models.Monster()
     {
         GenderId = 1, TitleId = 1, TypeId = 1, Name = "TestMonster", PicturePath = "TestPath"
     };
 }