public override bool Init(Client client) { int categoryId = 1; string[] url = BaseFuncs.GetAdditionalURLArray(client.URL, URL); if (url.Length > 1) { int.TryParse(url[1], out categoryId); } ProductCategory productCategory = productCategoryService.GetByID(categoryId); if (productCategory == null) { productCategory = productCategoryService.GetByID(1); } Hashtable data = new Hashtable(); data.Add("productCategory", productCategory); data.Add("menuActive", "catalog"); client.HttpSend(TemplateActivator.Activate(this, client, data)); return(true); }
public override bool Init(Client client) { int productCategoryID; if (int.TryParse(BaseFuncs.GetAdditionalURLArray(client.URL, this.URL)[0], out productCategoryID)) { ProductCategory productCategory = productCategoryService.GetByID(productCategoryID); if (productCategory != null) { Hashtable data = new Hashtable(); if (client.PostParam("EditProductCategory") != null) { if (client.PostParam("name") != null) { productCategory.Name = client.PostParam("name"); productCategory.Image = client.PostParam("image"); productCategory.Description = client.PostParam("desc"); productCategoryService.EditCategory(productCategory); client.Redirect("/product.category/#pr_" + productCategory.ID); Logger.ConsoleLog("Edited product category: " + productCategory.Name + " (ID: " + productCategory.ID + ")", ConsoleColor.Yellow); return(false); } } data.Add("ProductCategory", productCategory); client.HttpSend(TemplateActivator.Activate(this, client, data)); return(true); } } BaseFuncs.Show404(client); return(false); }
public ProductCategory GetCategory(Product product) { return(productCategoryService.GetByID(product.CategoryId)); }