예제 #1
0
        public bool InsertTitle(Models.Title title)
        {
            var n     = new SqlParameter("name", title.Name);
            var query = "insert into Monster.Title(TitleName, Active) values (@name, 1)";

            return(InsertData(query, n) == 1);
        }
예제 #2
0
        public bool DeleteTitle(Models.Title title)
        {
            var query = "delete Monster.Title where TitleId = @id";
            var id    = new SqlParameter("id", title.TitleId);
            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);
        }
예제 #3
0
        public bool UpdateTitle(Models.Title title)
        {
            var query  = "update Monster.Title set TitleName = @name, Active = @active where TitleId = @id";
            var name   = new SqlParameter("name", title.Name);
            var active = new SqlParameter("active", title.Active ? 1 : 0);
            var id     = new SqlParameter("id", title.TitleId);
            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"
     };
 }