Example #1
0
        public FakerTest()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            var dbContext = new ApplicationDbContext(config, null);

            EventRepository          = new EventRepository(dbContext);
            EventItemRepository      = new ItemRepository(dbContext);
            ContactRepository        = new ContactRepository(dbContext);
            IdentificationRepository = new IdentificationRepository(dbContext);


            var mapperConfig = new MapperConfiguration(CustomMapper.CreateConfigs);

            Mapper = new Mapper(mapperConfig);
        }
Example #2
0
        public ContactTest(ITestOutputHelper testOutputHelper)
        {
            _testOutputHelper = testOutputHelper;
            var config = new ConfigurationBuilder()
                         .AddInMemoryCollection(new[]
            {
                new KeyValuePair <string, string>("MongoConnection:ConnectionString", _runner.ConnectionString),
                new KeyValuePair <string, string>("MongoConnection:Database", "test")
            })
                         .Build();
            var dbContext = new ApplicationDbContext(config, _logger);

            ContactRepository        = new ContactRepository(dbContext);
            EmailRepository          = new EmailRepository(dbContext);
            IdentificationRepository = new IdentificationRepository(dbContext);
            var mapperConfig = new MapperConfiguration(CustomMapper.CreateConfigs);

            Mapper         = new Mapper(mapperConfig);
            ContactService = new ContactService(ContactRepository, Mapper, _contactLogger);
        }
        /// <summary>
        /// 将EditModel转为数据库实体
        /// </summary>
        /// <returns></returns>
        public Identification AsIdentification()
        {
            Identification identification = null;

            if (IdentificationId == 0)
            {
                identification = Identification.New();
            }
            else
            {
                identification =  new IdentificationRepository().Get(this.IdentificationId);
            }
            identification.IdNumber=this.IdNumber;
            identification.TrueName=this.TrueName;
            identification.IdentificationTypeId=this.IdentificationTypeId;
            identification.Description=this.Description;
            identification.Email=this.Email;
            identification.Mobile=this.Mobile;
            identification.UserId = UserContext.CurrentUser.UserId;
            identification.Status = IdentificationStatus.pending;

            return identification;
        }
 /// <summary>
 /// IdentificationService的构造函数
 /// </summary>
 /// <param name="identificationRepository"></param>
 /// <param name="identificationTypeRepository"></param>
 public IdentificationService(IdentificationRepository identificationRepository, IdentificationTypeRepository identificationTypeRepository)
 {
     this.iIdentificationRepository = identificationRepository;
     this.identificationTypeRepository = identificationTypeRepository;
 }