Exemplo n.º 1
0
 public ActionResult Create(RelationCateViewModel model)
 {
     ViewBag.Data_PID = GetSelectList();
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             RelationCate entity = new RelationCate();
             entity.CateName = model.CateName;
             entity.PID = model.PID == 0 ? null : model.PID;
             entity.Level = model.Level;
             entity.OrderIndex = model.OrderIndex;
             entity.Code = model.Code;
             cityService.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);
     }
 }
Exemplo n.º 2
0
 public void Update(RelationCate model)
 {
     var target = Find(model.ID);
     db.Attach<RelationCate>(target);
     target.CateName = model.CateName;
     target.PID = model.PID;
     target.Level = model.Level;
     target.Code = model.Code;
     target.OrderIndex = model.OrderIndex;
     db.Commit();
 }
Exemplo n.º 3
0
 public void Delete(RelationCate model)
 {
     var target = Find(model.ID);
     db.Remove<RelationCate>(target);
     db.Commit();
 }
Exemplo n.º 4
0
 public void Create(RelationCate model)
 {
     db.Add<RelationCate>(model);
     db.Commit();
 }