Exemplo n.º 1
0
        public bool InsertMonster(Models.Monster monster)
        {
            var genderid    = new SqlParameter("genderid", monster.GenderId);
            var titleid     = new SqlParameter("titleid", monster.TitleId);
            var typeid      = new SqlParameter("typeid", monster.TypeId);
            var name        = new SqlParameter("name", monster.Name);
            var picturepath = new SqlParameter("picturepath", monster.PicturePath);
            var query       = "insert into Monster.Monster(GenderId, TitleId, TypeId, Name, PicturePath, Active) values (@genderid, @titleid, @typeid, @name, @picturepath, 1)";

            return(InsertData(query, genderid, titleid, typeid, name, picturepath) == 1);
        }
Exemplo n.º 2
0
        public bool DeleteMonster(Models.Monster monster)
        {
            var query = "delete Monster.Monster where MonsterId = @id";
            var id    = new SqlParameter("id", monster.MonsterId);
            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);
        }
 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"
     };
 }
Exemplo n.º 4
0
        public bool UpdateMonster(Models.Monster monster)
        {
            var query       = "update Monster.Monster set GenderId = @genderid, TitleId = @titleid, TypeId = @typeid, Name = @name, PicturePath = @picturepath, Active = @active where MonsterId = @id";
            var genderid    = new SqlParameter("genderid", monster.GenderId);
            var titleid     = new SqlParameter("titleid", monster.TitleId);
            var typeid      = new SqlParameter("typeid", monster.TypeId);
            var name        = new SqlParameter("name", monster.Name);
            var picturepath = new SqlParameter("picturepath", monster.PicturePath);
            var active      = new SqlParameter("active", monster.Active ? 1 : 0);
            var id          = new SqlParameter("id", monster.MonsterId);
            int result;

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

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

            return(result >= 0);
        }