Exemple #1
0
 public AdoDataTests()
 {
     gender = new Models.Gender()
     {
         Name = "TestGender"
     };
 }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gender"></param>
        /// <returns></returns>
        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);
        }
Exemple #3
0
        //[Theory(gender = new Models.Gender() { Name = "blah", Active = true})]
        //[Theory(gender = new Models.Gender() { Name = "blah", Active = true })]
        //[Theory(gender = new Models.Gender() { Name = "blah", Active = true })]
        public void Theory_InsertGender(Models.Gender gender)
        {
            var data   = new AdoData();
            var actual = data.InsertGender(gender);

            Assert.True(actual);
        }
Exemple #4
0
        public static GenderDAO MapToGenderDAO(DA.Gender gender)
        {
            var g = new GenderDAO();

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

            return(g);
        }
Exemple #5
0
        public bool UpdateGender(Models.Gender gender)
        {
            var query  = "update Monster.Gender set Name = @name, Active = @active where GenderId = @id";
            var name   = new SqlParameter("name", gender.GenderName);
            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);
        }