public void Init()
 {
     gender = new Models.Gender()
     {
         Name = "TestGender"
     };
 }
예제 #2
0
        public bool InsertGender(Models.Gender gender)
        {
            var n     = new SqlParameter("name", gender.Name);
            var query = "insert into Monster.Gender(GenderName, Active) values (@name, 1)";

            return(InsertData(query, n) == 1);
        }
예제 #3
0
        public static GenderDAO MapToGenderDAO(M.Gender gender)
        {
            var g = new GenderDAO();

            g.Id   = gender.GenderId;
            g.Name = gender.Name;

            return(g);
        }
예제 #4
0
        public bool DeleteGender(Models.Gender gender)
        {
            var query = "delete Monster.Gender where GenderId = @id";
            var id    = new SqlParameter("id", gender.GenderId);
            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);
        }
예제 #5
0
        public bool UpdateGender(Models.Gender gender)
        {
            var query  = "update Monster.Gender set GenderName = @name, Active = @active where GenderId = @id";
            var name   = new SqlParameter("name", gender.Name);
            var active = new SqlParameter("active", gender.Active ? 1 : 0);
            var id     = new SqlParameter("id", gender.GenderId);
            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"
     };
 }
예제 #7
0
        public Models.Gender GetLatestGender()
        {
            try
            {
                var           ds           = GetDataDisconnected("SELECT TOP 1 * FROM Monster.Gender AS mg ORDER BY mg.GenderId DESC;");
                DataRow       row          = ds.Tables[0].Rows[0];
                Models.Gender latestGender = new Models.Gender()
                {
                    GenderId = int.Parse(row[0].ToString()),
                    Name     = row[1].ToString(),
                    Active   = bool.Parse(row[2].ToString())
                };

                return(latestGender);
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(null);
            }
        }