Beispiel #1
0
 public ActionResult Create(CityCateViewModel model)
 {
     ViewBag.Data_PID = GetSelectList();
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             CityCate entity = new CityCate();
             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);
     }
 }
Beispiel #2
0
        public ActionResult Edit(int ID)
        {
            CityCateViewModel model = new CityCateViewModel();
            var entity = cityService.Find(ID);
            model.CateName = entity.CateName;
            model.ID = entity.ID;
            model.Code = entity.Code;

            model.Level = entity.Level;
            model.OrderIndex = entity.OrderIndex;
            model.PID = entity.PID;
            ViewBag.Data_PID = GetSelectList(entity.PID.HasValue ? entity.PID.Value : 0);
            return View(model);
        }