public ActionResult Create(CustomerCateViewModel model) { ViewBag.Data_PID = GetSelectList(); ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { CustomerCate entity = new CustomerCate(); entity.CateName = model.CateName; entity.PID = model.PID == 0 ? null : model.PID; entity.Level = model.Level; entity.OrderIndex = model.OrderIndex; entity.Code = model.Code; CustomerService.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(CustomerCate model) { var target = Find(model.ID); db.Attach<CustomerCate>(target); target.CateName = model.CateName; target.PID = model.PID; target.Level = model.Level; target.Code = model.Code; target.OrderIndex = model.OrderIndex; db.Commit(); }
public void Delete(CustomerCate model) { var target = Find(model.ID); db.Remove<CustomerCate>(target); db.Commit(); }
public void Create(CustomerCate model) { db.Add<CustomerCate>(model); db.Commit(); }