public ActionResult Add(string Description) { if (ModelState.IsValid) { Category category = new Category(); try { category.Description = Description; category.Time = DateTime.Now; bllSession.ICategoryBLL.Insert(category); return Redirect("/Admin/Category/Index"); } catch { log.Error(new LogContent("增加分类出错", LogType.异常.ToString(), HttpHelper.GetIPAddress())); ModelState.AddModelError("", "增加分类出错!"); } } else { ModelState.AddModelError("", "你填写的信息有误!"); } return View(); }
public ActionResult Edit(Category model) { Category _category = new Category(); _category = bllSession.ICategoryBLL.GetEntity(model.Id); if (ModelState.IsValid) { try { Category category = new Category(); category = bllSession.ICategoryBLL.GetEntity(model.Id); category.Description = model.Description; bool result = bllSession.ICategoryBLL.Update(category); if (result) { return Redirect("/Admin/Category/Index/"); } else { log.Error(new LogContent(_category.Description + "修改分类出错", LogType.异常.ToString(), HttpHelper.GetIPAddress())); ModelState.AddModelError("", "修改分类出错"); } } catch { log.Error(new LogContent(_category.Description + "修改分类出错", LogType.异常.ToString(), HttpHelper.GetIPAddress())); ModelState.AddModelError("", "修改分类出错"); } } else { ModelState.AddModelError("", "填写数据有误"); } return View(_category); }
public ActionResult Edit(int id) { Category category = new Category(); category = bllSession.ICategoryBLL.GetEntity(id); return View(category); }