/// <summary> /// 更新和新增节点类型 /// </summary> /// <param name="input"></param> /// <returns></returns> public ScriptNodeTypeOutput InsertOrUpdateScriptNodeType(ScriptNodeTypeInput input) { if (_scriptNodeTypeRepository.GetAll().Any(p => p.Id != input.Id && p.Name == input.Name)) { throw new System.Exception("节点类型重复"); } //var type = AutoMapper.Mapper.Map<ScriptNodeTypeInput, ScriptNodeType>(input); var type = _scriptNodeTypeRepository.GetAll().FirstOrDefault(x => x.Id == input.Id) ?? new ScriptNodeType(); type = Fun.ClassToCopy(input, type, (new string[] { "Id" }).ToList()); var nodeType = _scriptNodeTypeRepository.InsertOrUpdate(type); if (nodeType != null) { return(AutoMapper.Mapper.Map <ScriptNodeTypeOutput>(nodeType)); } else { throw new UserFriendlyException("更新失败!"); } }
public ActionResult InsertScriptNodeType() { var model = new ScriptNodeTypeInput(); return(View("Easyman.FwWeb.Views.ScriptNode.EditScriptNodeType", model)); }