Ejemplo n.º 1
0
        public bool InsertGender(Model.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);
        }
Ejemplo n.º 2
0
 public AdoDataTests()
 {
     gender = new Model.Gender()
     {
         Name = "TestGender"
     };
 }
Ejemplo n.º 3
0
 public AdodataTests()
 {
     gender2 = new Model.Gender()
     {
         GenderID = 1, Name = "updatedName", Active = true
     };
 }
Ejemplo n.º 4
0
 public int GetRecentGender()
 {
     try
     {
         var          ds      = GetDataDisconnected("select top(1) * from Monster.Gender as mg order by mg.GenderId desc;");
         Model.Gender genders = new Model.Gender();
         genders.GenderID = int.Parse(ds.Tables[0].Rows[0][0].ToString());
         genders.Name     = ds.Tables[0].Rows[0][1].ToString();
         genders.Active   = bool.Parse(ds.Tables[0].Rows[0][2].ToString());
         int result = genders.GenderID;
         return(result);
     }
     catch (Exception)
     {
         return(0);
     }
 }
Ejemplo n.º 5
0
        public bool UpdateGender(Model.Gender gender)
        {
            var query  = "update Monster.Gender set Name = @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))
            {
                connection.Open();
                var cmd = new SqlCommand(query, connection);

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

            return(result == 1);
        }