public ActionResult EditDictionaryType(long?id) { var data = new DictionaryTypeModel(); if (id != null) { data = _DictionaryTypeAppService.GetDictionaryType(id.Value); } return(View("Easyman.FwWeb.Views.Dictionary.EditDictionaryType", data)); }
public override IType NormalizeTypeDeclaration(IType type) { if (type == null) { return(null); } if (type is ITypeModel) { return(type); } if (_visited.ContainsKey(type)) { return(_visited[type]); } if (type is PrimaryType) { _visited[type] = new PrimaryTypeModel(type as PrimaryType); return(_visited[type]); } if (type is SequenceType) { SequenceTypeModel model = new SequenceTypeModel(type as SequenceType); _visited[type] = model; return(NormalizeSequenceType(model)); } if (type is DictionaryType) { DictionaryTypeModel model = new DictionaryTypeModel(type as DictionaryType); _visited[type] = model; return(NormalizeDictionaryType(model)); } if (type is CompositeType) { CompositeTypeModel model = NewCompositeTypeModel(type as CompositeType); _visited[type] = model; return(NormalizeCompositeType(model)); } if (type is EnumType) { EnumTypeModel model = NewEnumTypeModel(type as EnumType); _visited[type] = model; return(NormalizeEnumType(model)); } throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Type {0} is not supported.", type.GetType())); }
/// <summary> /// 更新和新增字典类型 /// </summary> /// <param name="input"></param> /// <returns></returns> public DictionaryTypeModel InsertOrUpdateDictionaryType(DictionaryTypeModel input) { if (_DictionaryTypeCase.GetAll().Any(p => p.Id != input.Id && p.Name == input.Name)) { throw new UserFriendlyException("名为【" + input.Name + "】的对象已存在!"); } //使用MapTo和 Map会把没有传值过来的字段清空 //var entObj = AutoMapper.Mapper.Map<DictionaryType>(input); //var entObj = input.MapTo<DictionaryType>(); //使用框架方法Fun.ClassToCopy,复制一个类到另一个类进行赋值备注:需要排除ID(主键) var type = _DictionaryTypeCase.GetAll().FirstOrDefault(x => x.Id == input.Id) ?? new DictionaryType(); type = Fun.ClassToCopy(input, type, (new string[] { "Id" }).ToList()); var res = _DictionaryTypeCase.InsertOrUpdate(type); if (res == null) { throw new UserFriendlyException("新增或更新失败!"); } else { return(res.MapTo <DictionaryTypeModel>()); } }