public ActionResult Create(AreaCateViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { AreaCate entity = new AreaCate(); entity.CateName = model.CateName; AreaCateService.Create(entity); result.Message = "添加商业区分类成功!"; LogHelper.WriteLog("添加商业区分类成功"); return RedirectToAction("index"); } catch (DbEntityValidationException ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加商业区分类错误", ex); return View(model); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return View(model); } }
public void Update(AreaCate model) { var target = Find(model.ID); db.Attach<AreaCate>(target); target.CateName = model.CateName; db.Commit(); }
public void Delete(AreaCate model) { var target = Find(model.ID); db.Remove<AreaCate>(target); db.Commit(); }
public void Create(AreaCate model) { db.Add<AreaCate>(model); db.Commit(); }