Пример #1
0
        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");
        }
Пример #2
0
        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>("发生错误"));
        }