Ejemplo n.º 1
0
        public ActionResult Create(ControllerViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    ControllerService.Create(model);
                    result.Message = "添加控制器成功!";
                    LogHelper.WriteLog("添加控制器成功");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加控制器错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            return Json(result);
        }
Ejemplo n.º 2
0
 public Controller Update(ControllerViewModel model)
 {
     var entity = Find(model.ID);
     db.Attach<Controller>(entity);
     entity.Name = model.Name;
     entity.Description = model.Description;
     db.Commit();
     return entity;
 }
Ejemplo n.º 3
0
 public Controller Create(ControllerViewModel model)
 {
     var entity = new Controller();
     entity.Name = model.Name;
     entity.Description = model.Description;
     db.Add<Controller>(entity);
     db.Commit();
     return entity;
 }
Ejemplo n.º 4
0
 public ActionResult Edit(int ID)
 {
     var entity = ControllerService.Find(ID);
     var model = new ControllerViewModel()
     {
         ID = entity.ID,
         Description = entity.Description,
         Name = entity.Name
     };
     return PartialView(model);
 }
Ejemplo n.º 5
0
 public ActionResult Create()
 {
     var model = new ControllerViewModel();
     return PartialView(model);
 }