//
 // GET: /Category/
 public ActionResult Index()
 {
     var categoryBLL = new CategoryBLL();
     //ViewData["categories"] = categoryBLL.getAllCategories();
     //ViewData["category1"] = categoryBLL.getCategories1();
     ViewData["category1Model"] = categoryBLL.getCategoryModel();
     return View("Index");
 }
 //public ActionResult AddCategory(CategoryModel model)
 //{
 //    var effectedRow = new CategoryBLL().addCategory(model.totblCategory());
 //    return Content("" + effectedRow);
 //}
 public ActionResult Add(long? parent, string name)
 {
     var category = new tblCategory();
     category.parent = parent;
     category.name = name;
     int effected = new CategoryBLL().addCategory(category);
     return Content("" + effected);
 }
        public ActionResult Update(int id, int parent, string name)
        {
            var category = new tblCategory();
            category.id = id;
            category.parent = parent;
            category.name = name;

            var effectedRow = new CategoryBLL().UpdateCategory(category);
            return Content("" + effectedRow);
        }
 //
 // GET: /Product/
 public ActionResult Index(int categoryid=1)
 {
     var categoryModel = new CategoryBLL().getCategoryModel();
     var firstCategory2 = categoryModel.First().children.First();
     ViewData["Products"] = new ProductBLL().getProductsByCategoryId(firstCategory2.id);
     //if (categoryid == -1)
     //{
     //    ViewData["Products"] = new ProductBLL().getAllProducts();
     //}
     //else
     //{
     //    ViewData["Products"] = new ProductBLL().getProductsByCategoryId(categoryid);
     //}
     ViewData["category1Model"] = categoryModel;
     return View();
 }
 public ActionResult Delete(int id)
 {
     var effectedRow = new CategoryBLL().deleteCategory(id);
     return Content("" + effectedRow);
 }