Exemple #1
0
 public static bool Edit(Category cat)
 {
     return DataAccess.CreateInstance().EditCategory(cat);
 }
Exemple #2
0
        public static Collection<Category> CreateCategoriesFromReader(SqlDataReader reader)
        {
            Collection<Category> catlist = new Collection<Category>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Category c = new Category();

                    c.Id = Convert.ToInt32(reader["Id"]);
                    c.Name = Convert.ToString(reader["Name"]);
                    c.Slug = Convert.ToString(reader["Slug"]);

                    catlist.Add(c);
                }
            }

            return catlist;
        }
Exemple #3
0
        public bool EditCategory(Category cat)
        {
            int result;
            using (SqlConnection connection = this.GetConnection())
            {
                connection.Open();

                SqlCommand sc = new SqlCommand("EditCategory", connection);
                sc.CommandType = CommandType.StoredProcedure;
                sc.Parameters.AddWithValue("CategoryId", cat.Id);
                sc.Parameters.AddWithValue("Name", cat.Name);
                sc.Parameters.AddWithValue("Slug", cat.Slug);
                result = sc.ExecuteNonQuery();
            }

            return result == 1;
        }