public void ConfigAllMapAutoMapperTest() { var list = new List <Action <IMapperConfigurationExpression> >(); list.Add(ConfigAllMap); Action <IMapperConfigurationExpression> action = mapperConfigurationExpression => { FindAndAutoMapTypes(mapperConfigurationExpression); foreach (var configurator in list) { configurator(mapperConfigurationExpression); } }; Mapper.Initialize(action); var userInput = new AddUserInput { Name = "lex" }; var user = userInput.MapTo <User>(); user.Name.ShouldBe("lex"); }
public Result <int> AddUser(AddUserInput input) { var userCount = _userRepository.Count(); var user = input.MapTo <Domain.Core.Model.User>(); var result = _userRepository.Insert(user); if (result != null) { return(Result.FromData(userCount)); } return(Result.FromError <int>("发生错误")); }