public bool Update(ProductCategory item) { try { var category = db.ProductCategories.Find(item.ID); if (string.IsNullOrEmpty(item.MetaTitle)) { category.MetaTitle = StringHelper.ToUnsignString(item.Name); } category.Name = item.Name; category.ParentID = item.ParentID; category.SeoTitle = item.SeoTitle; category.ShowOnHome = item.ShowOnHome; category.Status = item.Status; category.DisplayOrder = item.DisplayOrder; category.MetaDescriptions = item.MetaDescriptions; category.MetaKeywords = item.MetaKeywords; category.ModifiedDate = DateTime.Now; db.SaveChanges(); } catch (Exception ex) { return false; } return true; }
public ActionResult Edit(ProductCategory model) { try { // TODO: Add update logic here var dao = new ProductCategoryDao(); dao.Update(model); return RedirectToAction("Index"); } catch { return View(); } }
public long Insert(ProductCategory model) { if (string.IsNullOrEmpty(model.MetaTitle)) { model.MetaTitle = StringHelper.ToUnsignString(model.Name); } model.CreatedBy ="Admin"; model.CreatedDate = DateTime.Now; db.ProductCategories.Add(model); db.SaveChanges(); return model.ID; }
public ActionResult Create(ProductCategory model) { try { // TODO: Add insert logic here var dao = new ProductCategoryDao(); var result = dao.Insert(model); return RedirectToAction("Index"); } catch { return View(); } }