Пример #1
0
        public ActionResult Create(CrowdCateViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    CrowdCate entity = new CrowdCate();
                    entity.CateName = model.CateName;

                    CrowdCateService.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);
            }
        }
Пример #2
0
 public ActionResult Edit(int ID)
 {
     CrowdCateViewModel model = new CrowdCateViewModel();
     var entity = CrowdCateService.Find(ID);
     model.CateName = entity.CateName;
     model.ID = entity.ID;
     return View(model);
 }