示例#1
0
        //get all list donate
        public List <DonateDTO> GetAll()
        {
            var data = _unitOfWork.DonateRepository.Get();

            CheckStatusForDonate();
            return(MapperProfile.MapperConfig().Map <List <Donate>, List <DonateDTO> >(data.ToList()));
        }
示例#2
0
 public DbFixture()
 {
     this.DbContext   = new AdventureWorksContext();
     this.Mapper      = MapperProfile.GetMapper();
     this.Repo        = new Repository(this.DbContext, this.Mapper);
     this.ProductRepo = new GenericRepository <Product>(this.DbContext);
 }
示例#3
0
        public void InserirTest()
        {
            using var context = new Context(options);
            context.Database.EnsureCreated();

            IRequisicaoService service = new RequisicaoService(context, MapperProfile.GetMapper());

            var retorno = service.Inserir(new PostRequisicaoModel
            {
                NrRequisicao      = 1,
                DsRequisicao      = "Teste",
                DtSolicitacao     = DateTime.Now,
                NmSolicitante     = "Fulano",
                OrdensDeLiberacao = new HashSet <PostOrdemDeLiberacaoModel>
                {
                    new PostOrdemDeLiberacaoModel {
                        NrOrdemDeLiberacao = 0
                    },
                    new PostOrdemDeLiberacaoModel {
                        NrOrdemDeLiberacao = 1, ProjetosAfetados = new HashSet <PostProjetoAfetadoModel>
                        {
                            new PostProjetoAfetadoModel {
                                CdProjeto = -1
                            },
                            new PostProjetoAfetadoModel {
                                CdProjeto = -2
                            },
                        }
                    },
                }
            });

            Assert.IsNotNull(retorno);
        }
示例#4
0
        public object GetUserById(int id)
        {
            var data = MapperProfile.MapperConfig().Map <User, UserDTO>(_unitOfWork.UserRepository.GetById(id));

            data.UserDonates = MapperProfile.MapperConfig().Map <List <UserDonate>, List <UserDonateDTO> >(_unitOfWork.UserDonateRepository.Get().Where(x => x.UserID == data.ID).ToList());
            return(data);
        }
示例#5
0
        public void TestMappingProfile()
        {
            var profile = new MapperProfile();
            var cfg     = new MapperConfiguration(c => c.AddProfile(profile));

            cfg.AssertConfigurationIsValid();
        }
示例#6
0
        public AboutUsDTO GetByid(int id)
        {
            var data = MapperProfile.MapperConfig().Map <AboutU, AboutUsDTO>(_unitOfWork.AboutUsRepository.GetById(id));

            data.LinkImage = baseUrl + data.AboutImage;
            return(data);
        }
示例#7
0
        private void CreateDefaultDeviceServiceInstance()
        {
            var services = new ServiceCollection();
            IServiceProvider serviceProvider = services.BuildServiceProvider();

            var myProfile     = new MapperProfile();
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(myProfile);
                cfg.ConstructServicesUsing(serviceProvider.GetService);
            });

            _mapper = new Mapper(configuration);

            _timetableRepository = new Mock <ITimetableRepository>();
            _timetableRepository.Setup(s => s.GetAllAsync(default(CancellationToken))).ReturnsAsync(_mapper.Map <List <Lesson> >(_fakeTimetable));
            _timetableRepository.Setup(s => s.GetByIdAsync(It.IsAny <Guid>(), default(CancellationToken))).ReturnsAsync(_mapper.Map <Lesson>(_fakeTimetable[1]));
            _timetableRepository.Setup(s => s.RemoveAsync(It.IsAny <Guid>(), default(CancellationToken))).ReturnsAsync(_mapper.Map <Lesson>(_fakeTimetable[1]));
            _timetableRepository.Setup(s => s.AddAsync(It.IsAny <Lesson>(), default(CancellationToken)));
            _timetableRepository.Setup(s => s.UpdateAsync(It.IsAny <Guid>(), It.IsAny <Lesson>(), default(CancellationToken)));

            _timetableRepository.Setup(s => s.DeleteAllLessons(default(CancellationToken)));
            _timetableRepository.Setup(s => s.GetFilteredAsync(It.IsAny <LessonFilter>(), default(CancellationToken)));
            _timetableRepository.Setup(s => s.InsertManyLesson(It.IsAny <List <Lesson> >(), default(CancellationToken)));
            _mockTimetableRepository = _timetableRepository.Object;
            _timetableService        = new TimetableService(_mockTimetableRepository, _mapper);
        }
示例#8
0
        public PartnerDTO GetByid(int id)
        {
            var data = MapperProfile.MapperConfig().Map <Partner, PartnerDTO>(_unitOfWork.PartnerRepository.GetById(id));

            data.LinkImage = baseUrl + data.PartnerImage;
            return(data);
        }
示例#9
0
        public void ObterTest()
        {
            using var context = new Context(options);
            IUsuarioService usuarioService = new UsuarioService(context, MapperProfile.GetMapper());
            var             user           = usuarioService.Obter(1);

            Assert.IsNotNull(user);
        }
示例#10
0
 public AccountApplication(IService <Person <User> > personService,
                           MapperProfile <PersonModel, Person <User> > userProfile,
                           UserService userService)
 {
     this._personService = personService;
     this._userProfile   = userProfile;
     this._userService   = userService;
 }
 public TransactionServices(TransactionRespository transactionRespository, MapperProfile mapperProfile, ScratchCardRepository scratchCardRepository, UserRespository userRespository)
 {
     this._transactionRespository = transactionRespository;
     this._mapperProfile          = mapperProfile;
     this._scratchCardRepository  = scratchCardRepository;
     this._userRespository        = userRespository;
     this._stackFrame             = new StackFrame();
 }
示例#12
0
        public void Bind(MapperProfile cfg)
        {
            cfg.CreateMap <UserAddModel, UserEntity>().ForMember(m => m.Roles, opt => opt.Ignore());
            cfg.CreateMap <UserSyncModel, UserEntity>().ForMember(m => m.Roles, opt => opt.Ignore());

            cfg.CreateMap <UserEntity, UserUpdateModel>();
            cfg.CreateMap <UserUpdateModel, UserEntity>().ForMember(m => m.Roles, opt => opt.Ignore());
        }
示例#13
0
        public AgentsControllerUnitTests()
        {
            mockLogger           = new Mock <ILogger <AgentsController> >();
            mockAgentsRepository = new Mock <IAgentsRepository>();
            var myProfile     = new MapperProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
            var mapper        = new Mapper(configuration);

            controller = new AgentsController(mockLogger.Object, mockAgentsRepository.Object, mapper);
        }
        public DotNetControllerUnitTests()
        {
            mockLogger     = new Mock <ILogger <DotNetMetricsController> >();
            mockRepository = new Mock <IDotNetMetricsRepository>();

            var myProfile     = new MapperProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
            var mapper        = new Mapper(configuration);

            controller = new DotNetMetricsController(mockLogger.Object, mockRepository.Object, mapper);
        }
示例#15
0
        public void ObterTest()
        {
            using var context = new Context(options);
            context.Database.EnsureCreated();

            IRequisicaoService service = new RequisicaoService(context, MapperProfile.GetMapper());

            var req = service.Obter().Include(r => r.OrdensDeLiberacao).FirstOrDefault();

            Assert.IsNotNull(req);
        }
示例#16
0
        public EmployeesControllerTests()
        {
            var myProfile     = new MapperProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));
            var mapper        = new Mapper(configuration);

            setUpDb();
            _mockUOW = new Mock <UnitOfWork>(_mockContext.Object);
            _mockBus = new EmployeeLookup(_mockUOW.Object);
            // _controller = new DemoEmployeeController(_mockBus,mapper);
        }
示例#17
0
 public UserServices(
     IUserRepository userRepository,
     MapperProfile mapper,
     UserManager <User> userManager,
     SignInManager <User> signInManager
     )
 {
     _userRepository = userRepository;
     _mapper         = mapper;
     _userManager    = userManager;
     _signInManager  = signInManager;
 }
示例#18
0
 public bool Edit(PartnerDTO partner)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <PartnerDTO, Partner>(partner);
         _unitOfWork.PartnerRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#19
0
 public bool Edit(TypeProgramDTO typeProgram)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <TypeProgram>(typeProgram);
         _unitOfWork.TypeProgramRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#20
0
        private void CreateDefaultApplicationUserServiceInstance()
        {
            var services = new ServiceCollection();

            var mockStore           = new Mock <IUserStore <ApplicationUser> >();
            var mockOptionsAccessor = new Mock <IOptions <IdentityOptions> >();
            var mockPasswordHasher  = new Mock <IPasswordHasher <ApplicationUser> >();
            var userValidators      = new List <IUserValidator <ApplicationUser> >();
            var validators          = new List <IPasswordValidator <ApplicationUser> >();
            var mockKeyNormalizer   = new Mock <ILookupNormalizer>();
            var mockErrors          = new Mock <IdentityErrorDescriber>();
            var mockServices        = new Mock <IServiceProvider>();
            var mockLogger          = new Mock <ILogger <UserManager <ApplicationUser> > >();

            var userManager = new UserManager <ApplicationUser>(mockStore.Object,
                                                                mockOptionsAccessor.Object,
                                                                mockPasswordHasher.Object,
                                                                userValidators,
                                                                validators,
                                                                mockKeyNormalizer.Object,
                                                                mockErrors.Object,
                                                                mockServices.Object,
                                                                mockLogger.Object);

            var userResolver = new UserResolver(userManager, _mapper);

            var bonusResolver = new BonusResolver(new Mock <IVendorService>().Object, new Mock <IBonusService>().Object, _mapper);

            services.AddTransient(sp => userManager);
            services.AddTransient(sp => userResolver);
            services.AddTransient(sp => bonusResolver);

            IServiceProvider serviceProvider = services.BuildServiceProvider();

            var myProfile     = new MapperProfile();
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(myProfile);
                cfg.ConstructServicesUsing(serviceProvider.GetService);
            });

            _mapper = new Mapper(configuration);
            _random = new Random();
            GenerateData();
            CreateMock();
            _userManager  = _userManagerMock.Object;
            _signManager  = _signManagerMock.Object;
            _tokenService = _tokenServiceMock.Object;
            _userService  = new UserService(_signManager, _userManager, _mapper, _fakeOptions, _tokenService);
        }
示例#21
0
 public bool Create(UserQuestionDTO userQuestion)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <UserQuestionDTO, UserQuestion>(userQuestion);
         _unitOfWork.UserQuestionRepository.Create(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#22
0
 public bool Edit(CategoryDTO category)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <Category>(category);
         _unitOfWork.CategoryRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#23
0
 public bool Edit(AboutUsDTO aboutUs)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <AboutUsDTO, AboutU>(aboutUs);
         _unitOfWork.AboutUsRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#24
0
 public bool Create(ProgramDTO program)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <ProgramDTO, Program>(program);
         _unitOfWork.ProgramRepository.Create(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#25
0
 public bool Edit(ProgramDTO program)
 {
     try
     {
         program.ProDateCreate = _unitOfWork.ProgramRepository.GetById(program.ID).ProDateCreate;
         var data = MapperProfile.MapperConfig().Map <ProgramDTO, Program>(program);
         _unitOfWork.ProgramRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
示例#26
0
        protected void Application_Start()
        {
            //注册autofac
            //DependencyInjector.Initialise();
            AutoFacBootStrapper.Register();
            HttpContext.Current.Application["Version"] = Version;
            InitLog4net();
            InitJsonNet();
            InitDbConnectionStringConfig();

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            MapperProfile.InitMapper();
        }
示例#27
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            //---------------myconf---------------------
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            //----------------endmyconf--------------------

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //---------------myconf---------------------
            MapperProfile.InitAutoMapper();
            //----------------endmyconf--------------------
        }
示例#28
0
        //
        public bool Create(DonateDTO donate)
        {
            try
            {
                donate.DonateStatus     = donate.StartDay > DateTime.Now ? DonateStatus.Upcoming : DonateStatus.Ongoing;
                donate.DonateDateCreate = DateTime.Now;
                donate.DonateHide       = false;

                var data = MapperProfile.MapperConfig().Map <DonateDTO, Donate>(donate);
                _unitOfWork.DonateRepository.Create(data);
                return(_unitOfWork.Commit());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
        public void SetUp()
        {
            repository = new Mock <IGymClassRepository>();
            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.Setup(u => u.GymClassRepository).Returns(repository.Object);

            mapper = new Mapper(new MapperConfiguration(cfg =>
            {
                var profile = new MapperProfile();
                cfg.AddProfile(profile);
            }));

            var userStore       = new Mock <IUserStore <ApplicationUser> >();
            var mockUserManager = new Mock <UserManager <ApplicationUser> >(userStore.Object, null, null, null, null, null, null, null, null);

            controller = new GymClassesController(mockUoW.Object, mockUserManager.Object, mapper);
        }
示例#30
0
        public UserDTO Register(UserDTO user)
        {
            var userData = MapperProfile.MapperConfig().Map <UserDTO, User>(user);

            userData.UserPwd        = Encrypt.EncryptPasswordMD5(userData.UserPwd);
            userData.UserDateCreate = DateTime.Now;
            userData.UserActive     = true;
            //add only user role;
            userData.RoleID = 2;
            var userd = _unitOfWork.UserRepository.CreateOnlyData(userData);

            if (_unitOfWork.Commit())
            {
                return(user);
            }
            ;
            return(null);
        }