public ActionResult EditBrand(long id) { var dao = new BrandDao(); var brand = dao.GetByID(id); SetViewBag(brand.Category_ID); return(View()); }
public ActionResult Edit(ProductViewModel entity) { if (ModelState.IsValid) { var product = new Product(); product.ID = entity.ID; product.Name = entity.Name.Trim(); product.MetaTitle = entity.MetaTitle; product.Description = entity.Description; product.Image = entity.Image; product.MoreImages = entity.MoreImages; product.Price = entity.Price; product.CategoryID = entity.CategoryID; product.Detail = entity.Detail; product.BrandID = entity.BrandID; product.Status = entity.Status; product.TopHot = entity.TopHot; var productDao = new ProductDao(); var categoryDao = new CategoryDao(); var brandDao = new BrandDao(); long result = productDao.Update(product); if (result > 0) { ShowNotify("Update successfully", "success"); return(RedirectToAction("Index", "Product")); } else if (result == -1) { ShowNotify("This '" + categoryDao.GetByID(product.CategoryID).Name + "' category is locked", "error"); } else if (result == -2) { ShowNotify("This '" + brandDao.GetByID(product.BrandID).Name + "' brand is locked", "error"); } else if (result == -3) { ShowNotify("Input price of product please !!!", "error"); } else { ShowNotify("System error", "error"); } } SetViewBagBrand(entity.BrandID, false); SetViewBagCategory(entity.CategoryID, false); return(View("Edit")); }
public ActionResult Edit(string id) { if (id == null || !Regex.IsMatch(id, @"\d")) { return(RedirectToAction("Index", "Brand")); } var brandDao = new BrandDao(); var product = brandDao.GetByID(Int32.Parse(id)); if (product == null) { return(RedirectToAction("Index", "Brand")); } return(View(product)); }