public Category GetCategoryById(int catId)
        {
            var category = new Category();
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("GetCategoryById", cn) { CommandType = CommandType.StoredProcedure };
                cmd.Parameters.AddWithValue("@CategoryId", catId);

                cn.Open();

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var cat = new Category
                        {
                            CategoryId = dr.GetInt32(0),
                            CategoryName = dr.GetString(1)
                        };
                        return cat;
                    }
                }
            }
            return null;
        }
 public void DeleteCategory(Category category)
 {
     using (var cn = new SqlConnection(Settings.GetConnectionString()))
     {
         var cmd = new SqlCommand("DeleteCategory", cn) { CommandType = CommandType.StoredProcedure };
         cmd.Parameters.AddWithValue("@CategoryId", category.CategoryId);
         cn.Open();
         cmd.ExecuteNonQuery();
     }
 }
        public ActionResult Edit(int id, Category cat)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Create(Category cat)
        {
            try
            {
                category.AddCategory(cat);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public List<Category> GetAllCategories()
        {
            var category = new List<Category>();
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("GetAllCategories", cn) { CommandType = CommandType.StoredProcedure };

                cn.Open();

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var cat = new Category
                        {
                            CategoryId = dr.GetInt32(0),
                            CategoryName = dr.GetString(1)
                        };
                        category.Add(cat);
                    }
                }
            }
            return category;
        }
 public void EditCategory(Category category)
 {
     _categoryRepo.EditCategory(category);
 }
 public void DeleteCategory(Category category)
 {
     _categoryRepo.DeleteCategory(category);
 }
 public void AddCategory(Category category)
 {
     _categoryRepo.AddCategory(category);
 }