public CallMmCodeDataProvider(IAmDataProvider dataProvider, IReadOnlyRepository repository, ILogCommandTypes logCommand)
 {
     _log = LogManager.GetLogger(GetType());
     _dataProvider = dataProvider;
     _repository = repository;
     _logCommand = logCommand;
 }
示例#2
0
        public NewUserModule(IPasswordEncryptor passwordEncryptor, ICommandDispatcher commandDispatcher,
                             IReadOnlyRepository readOnlyRepository)
        {
            Post["/user/facebook"] = r =>
                                         {
                                             var newUserRequest = this.Bind<NewUserRequest>();
                                             CheckForExistingFacebookUser(readOnlyRepository, newUserRequest);
                                             DispatchCommand(commandDispatcher, newUserRequest);
                                             return new Response().WithStatusCode(HttpStatusCode.OK);
                                         };

            Post["/user"] = r =>
                                {
                                    var newUserRequest = this.Bind<NewUserRequest>();
                                    CheckForExistingUser(readOnlyRepository, newUserRequest);
                                    commandDispatcher.Dispatch(this.VisitorSession(), new NewUserCommand
                                                                                          {
                                                                                              Email =
                                                                                                  newUserRequest.Email,
                                                                                              EncryptedPassword =
                                                                                                  passwordEncryptor.
                                                                                                  Encrypt(
                                                                                                      newUserRequest.
                                                                                                          Password)
                                                                                          });
                                    return new Response().WithStatusCode(HttpStatusCode.OK);
                                };
        }
示例#3
0
        public LoginModule(
            IReadOnlyRepository readOnlyRepository, 
            IPasswordEncryptor passwordEncryptor,
            IUserSessionFactory userSessionFactory)
        {
            
            Post["/login"] =
                r =>
                    {
                        var loginInfo = this.Bind<LoginRequest>();

                        EncryptedPassword encryptedPassword = passwordEncryptor.Encrypt(loginInfo.Password);

                        try
                        {
                            var user =
                            readOnlyRepository.First<User>(
                                x => x.Email == loginInfo.Email && x.EncryptedPassword == encryptedPassword.Password);

                            if (!user.Activated) return new Response().WithStatusCode(HttpStatusCode.Forbidden);

                            var userSession = userSessionFactory.Create(user);

                            return new SuccessfulLoginResponse<Guid>(userSession.Id, userSession.Expires);
                        }
                        catch (ItemNotFoundException<User> ex)
                        {
                            return new Response().WithStatusCode(HttpStatusCode.Unauthorized);
                        }
                    };
        }
示例#4
0
        public UserModule(IMappingEngine mappingEngine, IReadOnlyRepository readOnlyRepository)
        {
            Get["/me"] = r => mappingEngine.Map<User, MeResponse>(this.UserSession().User);

            Get["/user/exists"] =
                r =>
                    {
                        bool exists = false;
                        bool activated = false;
                        var email = (string) Request.Query.email;
                        try
                        {
                            var user =
                                readOnlyRepository.First<User>(x => x.Email == email);
                            exists = true;
                            activated = user.Activated;
                        }
                        catch (ItemNotFoundException<User>)
                        {
                        }
                        return new UserExistenceResponse
                                   {
                                       Exists = exists,
                                       Activated = activated,
                                   };
                    };
        }
示例#5
0
        public LoginModule(IPasswordEncryptor passwordEncryptor, IReadOnlyRepository readOnlyRepository,
            IUserSessionFactory userSessionFactory)
        {
            Post["/login"] =
                _ =>
                {
                    var loginInfo = this.Bind<LoginRequest>();
                    if (loginInfo.Email == null) throw new UserInputPropertyMissingException("Email");
                    if (loginInfo.Password == null) throw new UserInputPropertyMissingException("Password");

                    EncryptedPassword encryptedPassword = passwordEncryptor.Encrypt(loginInfo.Password);

                    try
                    {
                        var user =
                            readOnlyRepository.First<User>(
                                x => x.Email == loginInfo.Email && x.EncryptedPassword == encryptedPassword.Password);

                        UserLoginSession userLoginSession = userSessionFactory.Create(user);

                        return new SuccessfulLoginResponse<Guid>(userLoginSession.Id, user.Id, user.Name,
                            userLoginSession.Expires);
                    }
                    catch (ItemNotFoundException<User>)
                    {
                        throw new UnauthorizedAccessException();
                    }
                };
        }
 public when_getting_car_information()
 {
     _request = LaceRequestCarInformationRequestBuilder.ForCarId_107483_ButNoVin();
     _repository = new FakeCarInfoRepository();
     _vin12Repository = new FakeVin12CarInfoRepository(_request.Vin);
     _getCarInformation = new CarInformationQuery(_repository);
 }
示例#7
0
        public UserModule(IMappingEngine mappingEngine, IReadOnlyRepository readOnlyRepository)
        {
            Get["/me"] = r =>
                             {
                                 return mappingEngine.Map<User, MeResponse>(this.UserSession().User);
                             };

            Get["/user/exists"] =
                r =>
                {
                    bool exists = false;
                    bool activated = false;
                    var facebookid = (long)Request.Query.facebookid;
                    try
                    {
                        var user =
                            readOnlyRepository.First<User>(x => x.FacebookId == facebookid);
                        if (user != null)
                        {
                            exists = true;
                            activated = user.Verified;
                        }

                    }
                    catch (ItemNotFoundException<User>)
                    {
                    }
                    return new UserExistenceResponse
                    {
                        Exists = exists,
                        Activated = activated,
                    };
                };
        }
 public when_adding_bands_to_the_cache()
 {
     _repository = new CacheDataRepository();
     _band = new Band();
     _clearing = new ClearData(_repository);
     _readRepository = new DataProviderRepository();
 }
示例#9
0
 public CardController(IReadOnlyRepository readOnlyRepository, IWriteOnlyRepository writeOnlyRepository,
     IMappingEngine mappingEngine)
 {
     _readOnlyRepository = readOnlyRepository;
     _writeOnlyRepository = writeOnlyRepository;
     _mappingEngine = mappingEngine;
 }
 public BaseRetrievalMetric(IHaveCarInformation request, IRespondWithValuation valuation,
     IReadOnlyRepository repository)
 {
     _request = request;
     _repository = repository;
     Valuation = valuation;
 }
        public when_adding_sale_data_to_the_cache()
        {
            _repository = new CacheDataRepository();
            _sale = new Sale();
            _clearing = new ClearData(_repository);
            _readRepository = new DataProviderRepository();

        }
示例#12
0
 public ProjectRepository(IReadOnlyRepository readOnlyRepository, IWriteableRepository writeableRepository,
     IBlingDispatcher dispatcher, ITransactionManager transactionManager)
 {
     _readOnlyRepository = readOnlyRepository;
     _writeableRepository = writeableRepository;
     _dispatcher = dispatcher;
     _transactionManager = transactionManager;
 }
        public when_refreshing_objects_in_the_cache()
        {
            _repository = new CacheDataRepository();
            _readRepository = new DataProviderRepository();

            _clearing = new ClearData(_repository);
            _refreshing = new RefreshData(_repository);
        }
 public AccountController(IReadOnlyRepository readOnlyRepository, IWriteOnlyRepository writeOnlyRepository,
     IMappingEngine mappingEngine, IRegisterValidator<AccountRegisterModel> registerValidator)
 {
     _readOnlyRepository = readOnlyRepository;
     _writeOnlyRepository = writeOnlyRepository;
     _mappingEngine = mappingEngine;
     _registerValidator = registerValidator;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyPriceHistoryRepository"/> class.
        /// </summary>
        /// <param name="repository">The repository.</param>
        public ReadOnlyPriceHistoryRepository(IReadOnlyRepository<HistoricPrice> repository)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            this.repository = repository;
        }
 public ProductDataBuilder(IReadOnlyRepository<Lawnmower> lawnMowerRepository,
     IReadOnlyRepository<PhoneCase> phoneCaseRepository,
     IReadOnlyRepository<TShirt> tShirtRepository
     )
 {
     _lawnMowerRepository = lawnMowerRepository;
     _phoneCaseRepository = phoneCaseRepository;
     _tShirtRepository = tShirtRepository;
 }
示例#17
0
 public SchedulerPresenter(ISchedulerView schedulerView, IReadOnlyRepository<SupportPresse, Guid> repositoryPresse, IReadOnlyRepository<SupportTV, Guid> repositoryTV, IReadOnlyRepository<SupportRadio, Guid> repositoryRadio, IRepository<Filter, Guid> repositoryFilter, IRepository<Vague, Guid> repositoryVague)
 {
     _schedulerView = schedulerView;
     _repositoryFilter = repositoryFilter;
     _repositoryRadio = repositoryRadio;
     _repositoryTV = repositoryTV;
     _repositorypresse = repositoryPresse;
     _repositoryVague = repositoryVague;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyStockRepository"/> class.
        /// </summary>
        /// <param name="readOnlyRepository">The read-only repository.</param>
        public ReadOnlyStockRepository(IReadOnlyRepository<Stock> readOnlyRepository)
        {
            if (readOnlyRepository == null)
            {
                throw new ArgumentNullException("readOnlyRepository");
            }

            this.repository = readOnlyRepository;
        }
 public static void OfBaseRetrievalMetric(IHaveCarInformation request, IReadOnlyRepository repository, out IRetrieveValuationFromMetrics metrics)
 {
     metrics =
        new BaseRetrievalMetric(request, new Valuation(),
            repository)
            .SetupDataSources()
            .GenerateData()
            .BuildValuation();
 }
示例#20
0
 public MainHub(IReadOnlyRepository <AppUser, Guid> AppUserRepository,
                IMessGroupService _MessGroupService,
                IUserMessageService _UserMessageService,
                IHubContext <NotificationHub> _NotificationHub)
 {
     this.AppUserRepository   = AppUserRepository;
     this._MessGroupService   = _MessGroupService;
     this._UserMessageService = _UserMessageService;
     this._NotificationHub    = _NotificationHub;
 }
示例#21
0
 public AppRoleService(IRepository <AppRole, string> appRoleRepository,
                       IRepository <RoleGroup, string> roleGroupRepository,
                       IReadOnlyRepository readOnlyRepository,
                       IRepository <UserRole, string> userRoleRepository)
 {
     _userRoleRepository  = userRoleRepository;
     _appRoleRepository   = appRoleRepository;
     _roleGroupRepository = roleGroupRepository;
     _readOnlyRepository  = readOnlyRepository;
 }
 public CartsController(ICartReader cartReader,
                        ICartWriter cartWriter,
                        IReadOnlyRepository <Customer> customerRepository,
                        IReadOnlyRepository <Product> productRepository)
 {
     _cartReader         = cartReader;
     _cartWriter         = cartWriter;
     _customerRepository = customerRepository;
     _productRepository  = productRepository;
 }
示例#23
0
        public static async Task <long> LongCountAsync <T>(
            [NotNull] this IReadOnlyRepository <T> repository,
            [NotNull] Expression <Func <T, bool> > predicate,
            CancellationToken cancellationToken = default)
            where T : class, IEntity
        {
            var queryable = await repository.GetQueryableAsync();

            return(await repository.AsyncExecuter.LongCountAsync(queryable, predicate, cancellationToken));
        }
示例#24
0
        public static async Task <float?> AverageAsync <T>(
            [NotNull] this IReadOnlyRepository <T> repository,
            [NotNull] Expression <Func <T, float?> > selector,
            CancellationToken cancellationToken = default)
            where T : class, IEntity
        {
            var queryable = await repository.GetQueryableAsync();

            return(await repository.AsyncExecuter.AverageAsync(queryable, selector, cancellationToken));
        }
示例#25
0
        public static async Task <bool> ContainsAsync <T>(
            [NotNull] this IReadOnlyRepository <T> repository,
            [NotNull] T item,
            CancellationToken cancellationToken = default)
            where T : class, IEntity
        {
            var queryable = await repository.GetQueryableAsync();

            return(await repository.AsyncExecuter.ContainsAsync(queryable, item, cancellationToken));
        }
示例#26
0
 public Service(
     IRepository <TEntity> repository,
     IReadOnlyRepository <TEntity> readOnlyRepository,
     IValidation <TEntity> validation)
 {
     _repository         = repository;
     _readOnlyRepository = readOnlyRepository;
     _validation         = validation;
     _validationResult   = new ValidationResult();
 }
示例#27
0
        public static IQueryable <TEntity> GetFilteredEntities <TEntity>(this IReadOnlyRepository <TEntity> repository, Expression <Func <TEntity, bool> > filterExpression) where TEntity : class
        {
            var queryable = repository.GetEntities();

            if (filterExpression != null)
            {
                queryable = queryable.Where(filterExpression);
            }
            return(queryable);
        }
示例#28
0
 public ProductDataConsolidator(
     IReadOnlyRepository <Lawnmower> lawnmowerRepository,
     IReadOnlyRepository <PhoneCase> phoneCaseRepository,
     IReadOnlyRepository <TShirt> teeShirtRepository
     )
 {
     this.lawnmowerRepository = lawnmowerRepository;
     this.phoneCaseRepository = phoneCaseRepository;
     this.teeShirtRepository  = teeShirtRepository;
 }
        public static async Task ValidateUniqueEmail(IReadOnlyRepository readOnlyRepository, AddExampleModel request)
        {
            var query  = readOnlyRepository.Query <Example>(x => x.Status == EnabledStatus.Enabled && x.Email == request.Email);
            var exists = await readOnlyRepository.AnyAsync(query);

            if (exists)
            {
                throw new ObjectValidationException(nameof(request.Email), $"Email {request.Email} is already assigned to an example.");
            }
        }
示例#30
0
        public CachedRepositoryDecorator(IReadOnlyRepository <Entity> repository)
        {
            cacheOptions = new MemoryCacheEntryOptions();
            cacheOptions.SetAbsoluteExpiration(relative: TimeSpan.FromSeconds(120));

            _cache = new MemoryCache(new MemoryCacheOptions());

            // 5 second cache
            // cacheOptions =
        }
示例#31
0
 public CartUpdater(IReadOnlyRepository <Customer> customerRepository,
                    IReadOnlyRepository <Product> productRepository,
                    IRepository <CartReadModel> cartRepository,
                    IRepository <CartItemReadModel> cartItemRepository)
 {
     _customerRepository = customerRepository;
     _productRepository  = productRepository;
     _cartRepository     = cartRepository;
     _cartItemRepository = cartItemRepository;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MedicalAppointments"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="medicalAppointmentReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="MedicalModels.MedicalAppointment"/> records from the repository
 /// </param>
 /// <param name="medicalAppointmentRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="MedicalModels.MedicalAppointment"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <seealso cref="ILogger{T}"/> to use to log messages
 /// </param>
 /// <param name="kernel">
 /// The <seealso cref="IKernel"/> to use for dependency injection
 /// </param>
 public MedicalAppointments(
     IReadOnlyRepository<MedicalModels.MedicalAppointment> medicalAppointmentReadOnlyRepository,
     IRepository<MedicalModels.MedicalAppointment> medicalAppointmentRepository,
     ILogger<MedicalAppointments> logger,
     IKernel kernel)
 {
     this.medicalAppointmentReadOnlyRepository = medicalAppointmentReadOnlyRepository;
     this.medicalAppointmentRepository = medicalAppointmentRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
示例#33
0
 public FrontendAppService(
     IReadOnlyRepository <Hotel, Guid> hotelRepository,
     IReadOnlyRepository <HotelType, Guid> hotelTypeRepository,
     IReadOnlyRepository <Address, Guid> addressRepository,
     IAsyncQueryableExecuter asyncExecuter)
 {
     _hotelRepository     = hotelRepository;
     _hotelTypeRepository = hotelTypeRepository;
     _addressRepository   = addressRepository;
     _asyncExecuter       = asyncExecuter;
 }
 public CreateBucketCommandHandler(
     IUserContext userContext,
     IRepository <Bucket> bucketRepository,
     IReadOnlyRepository <Currency> currencyRepository,
     IMapperDefinition <CreateBucketCommand, Bucket> mapperDefinition)
 {
     _userContext        = userContext ?? throw new ArgumentNullException(nameof(userContext));
     _bucketRepository   = bucketRepository ?? throw new ArgumentNullException(nameof(bucketRepository));
     _currencyRepository = currencyRepository ?? throw new ArgumentNullException(nameof(currencyRepository));
     _mapperDefinition   = mapperDefinition ?? throw new ArgumentNullException(nameof(mapperDefinition));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PrescriptionPickups"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="prescriptionPickupkReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="PrescriptionModels.PrescriptionPickup"/> records from the repository
 /// </param>
 /// <param name="prescriptionPickupRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="PrescriptionModels.PrescriptionPickup"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <seealso cref="ILogger{T}"/> to use to log messages
 /// </param>
 /// <param name="kernel">
 /// The <seealso cref="IKernel"/> to use for dependency injection
 /// </param>
 public PrescriptionPickups(
     IReadOnlyRepository<PrescriptionModels.PrescriptionPickup> prescriptionPickupkReadOnlyRepository,
     IRepository<PrescriptionModels.PrescriptionPickup> prescriptionPickupRepository,
     ILogger<PrescriptionPickups> logger,
     IKernel kernel)
 {
     this.prescriptionPickupkReadOnlyRepository = prescriptionPickupkReadOnlyRepository;
     this.prescriptionPickupRepository = prescriptionPickupRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthorizationNotes"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="authorizationNoteReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="InsuranceModels.AuthorizationNote"/> records from the repository
 /// </param>
 /// <param name="authorizationNoteRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="InsuranceModels.AuthorizationNote"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <seealso cref="ILogger{T}"/> to use to log messages
 /// </param>
 /// <param name="kernel">
 /// The <seealso cref="IKernel"/> to use for dependency injection
 /// </param>
 public AuthorizationNotes(
     IReadOnlyRepository<InsuranceModels.AuthorizationNote> authorizationNoteReadOnlyRepository,
     IRepository<InsuranceModels.AuthorizationNote> authorizationNoteRepository,
     ILogger<AuthorizationNotes> logger,
     IKernel kernel)
 {
     this.authorizationNoteReadOnlyRepository = authorizationNoteReadOnlyRepository;
     this.authorizationNoteRepository = authorizationNoteRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Medications"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="medicationReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="PrescriptionModels.Medication"/> records from the repository
 /// </param>
 /// <param name="medicationRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="PrescriptionModels.Medication"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <seealso cref="ILogger{T}"/> to use to log messages
 /// </param>
 /// <param name="kernel">
 /// The <seealso cref="IKernel"/> to use for dependency injection
 /// </param>
 public Medications(
     IReadOnlyRepository<PrescriptionModels.Medication> medicationReadOnlyRepository,
     IRepository<PrescriptionModels.Medication> medicationRepository,
     ILogger<Medications> logger,
     IKernel kernel)
 {
     this.medicationReadOnlyRepository = medicationReadOnlyRepository;
     this.medicationRepository = medicationRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
        public override void Get(BusinessObject sender, BusinessConsultEventArgs args)
        {
            IReadOnlyRepository <DtoUser> repository = repositoryFactory.CreateReadOnlyUsersRepository();
            DtoUser dtoUser = repository.Get(args.entityId);
            User    user    = new User(dtoUser.ID, dtoUser.UserName, dtoUser.Hash, dtoUser.Active, sender.GetBusinessEvents());

            args.result = new List <User>()
            {
                user
            };
        }
 public DashboardIndexModel(
     IExamCategoryService _ExamCategoryService,
     IExamLogService _ExamLogService,
     IScoreLogService _ScoreLogService,
     IReadOnlyRepository <ExamCatInstructor, Guid> _ExamCatInstructorRepository)
 {
     this._ExamCategoryService         = _ExamCategoryService;
     this._ExamLogService              = _ExamLogService;
     this._ScoreLogService             = _ScoreLogService;
     this._ExamCatInstructorRepository = _ExamCatInstructorRepository;
 }
示例#40
0
        public EntityService(IReadOnlyRepository <Country, short> countryRepository,
                             IRepository <Bank, int> bankRepository,
                             IRepository <Branch, int> branchRepository,
                             IUnitOfWork unitOfWork)
        {
            this.CountryRepository = (countryRepository as ICountryRepository);
            this.BankRepository    = (bankRepository as IBankRepository);
            this.BranchRepository  = (branchRepository as IBranchRepository);

            this.UnitOfWork = unitOfWork;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Accounts"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="accountReadRepository">
 /// The <c>IReadOnlyRepository</c> to use
 /// for retrieving <c>Account</c> records from the repository
 /// </param>
 /// <param name="accountRepository">
 /// The <c>IRepository</c> to use
 /// for adding, deleting, and updating <c>Account</c> records in the 
 /// repository
 /// </param>
 /// <param name="logger">
 /// The <c>ILogger</c> to user to log messages
 /// </param>
 /// <param name="kernel">
 /// The <c>IKernel</c> to use for dependency injection
 /// </param>
 public Accounts(
     IReadOnlyRepository<AccountModels.Account> accountReadRepository,
     IRepository<AccountModels.Account> accountRepository,
     ILogger<Accounts> logger,
     IKernel kernel)
 {
     this.accountReadRepository = accountReadRepository;
     this.accountRepository = accountRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Insurers"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="insurerReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="InsuranceModels.Insurer"/> records from the repository
 /// </param>
 /// <param name="insurerRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="InsuranceModels.Insurer"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <seealso cref="ILogger{T}"/> to use to log messages
 /// </param>
 /// <param name="kernel">
 /// The <seealso cref="IKernel"/> to use for dependency injection
 /// </param>
 public Insurers(
     IReadOnlyRepository<InsuranceModels.Insurer> insurerReadOnlyRepository,
     IRepository<InsuranceModels.Insurer> insurerRepository,
     ILogger<Insurers> logger,
     IKernel kernel)
 {
     this.insurerReadOnlyRepository = insurerReadOnlyRepository;
     this.insurerRepository = insurerRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
        public override void GetAll(BusinessObject sender, BusinessConsultEventArgs args)
        {
            IReadOnlyRepository <DtoUser> repository = repositoryFactory.CreateReadOnlyUsersRepository();
            List <User> list = new List <User>();

            foreach (DtoUser dto in repository.GetAll())
            {
                list.Add(new User(dto.ID, dto.UserName, dto.Hash, dto.Active, sender.GetBusinessEvents()));
            }
            args.result = list;
        }
示例#44
0
 public NewUserModule(IPasswordEncryptor passwordEncryptor, ICommandDispatcher commandDispatcher,
                      IReadOnlyRepository readOnlyRepository)
 {
     Post["/user"] = r =>
                         {
                             var newUserRequest = this.Bind<NewUserRequest>();
                             CheckForExistingUser(readOnlyRepository, newUserRequest);
                             DispatchCommand(passwordEncryptor, commandDispatcher, newUserRequest);
                             return new Response().WithStatusCode(HttpStatusCode.OK);
                         };
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Facilities"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="facilityReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="MedicalModels.Facility"/> records from the repository 
 /// </param>
 /// <param name="facilityRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="MedicalModels.Facility"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <c>ILogger</c> to user to log messages
 /// </param>
 /// <param name="kernel">
 /// The <c>IKernel</c> to use for dependency injection
 /// </param>
 public Facilities(
     IReadOnlyRepository<MedicalModels.Facility> facilityReadOnlyRepository,
     IRepository<MedicalModels.Facility> facilityRepository,
     ILogger<Facilities> logger,
     IKernel kernel)
 {
     this.facilityReadOnlyRepository = facilityReadOnlyRepository;
     this.facilityRepository = facilityRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
示例#46
0
 public TokensController(
     ICommandSender bus,
     IReadOnlyRepository <Token> repository,
     ITokenSecurity tokenSecurity,
     IFindAccount accounts)
 {
     this.bus           = bus;
     this.repository    = repository;
     this.tokenSecurity = tokenSecurity;
     this.accounts      = accounts;
 }
示例#47
0
 protected QueryHandler(
     IMapper mapper,
     IReadOnlyRepository repository,
     IComponentContext scope,
     IWorkerContext <TOut> context) : base(
         mapper, context, scope)
 {
     Repository       = repository;
     HandlerDelegates = scope.Resolve <QueryHandlerDelegates <TRequestDto, TEntity, TOut> >();
     scope.Resolve <IEnumerable <IQueryHandlerDelegates <TRequestDto, TEntity, TOut> > >().ToList();
 }
示例#48
0
 public AdminController(IUserStore <IdentityUser> users,
                        IReadWriteRepository readWriteRepository,
                        IReadOnlyRepository readOnlyRepository,
                        IMapper mapper)
     : base(users, readOnlyRepository, mapper)
 {
     _users = users;
     _readWriteRepository = readWriteRepository;
     _readOnlyRepository  = readOnlyRepository;
     _mapper = mapper;
 }
示例#49
0
 public static void Import(IRepository destination,IReadOnlyRepository sourceRepository)
 {
     var getKeys = sourceRepository as IGetKeys;
     if(getKeys != null)
     {
         foreach(var key in getKeys.GetKeys())
         {
             destination.Set(key, sourceRepository.Get(key));
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Providers"/> class.
 /// Interfaces are used for initialization to facilitate dependency injection.
 /// </summary>
 /// <param name="providerReadOnlyRepository">
 /// The <seealso cref="IReadOnlyRepository{T}"/> to use for retrieving 
 /// <seealso cref="MedicalModels.Provider"/> records from the repository
 /// </param>
 /// <param name="providerRequestRepository">
 /// The <seealso cref="IRepository{T}"/> to use for adding, deleting, and updating 
 /// <seealso cref="MedicalModels.Provider"/> records in the  repository
 /// </param>
 /// <param name="logger">
 /// The <seealso cref="ILogger{T}"/> to use to log messages
 /// </param>
 /// <param name="kernel">
 /// The <seealso cref="IKernel"/> to use for dependency injection
 /// </param>
 public Providers(
     IReadOnlyRepository<MedicalModels.Provider> providerReadOnlyRepository,
     IRepository<MedicalModels.Provider> providerRequestRepository,
     ILogger<Providers> logger,
     IKernel kernel)
 {
     this.providerReadOnlyRepository = providerReadOnlyRepository;
     this.providerRequestRepository = providerRequestRepository;
     this.logger = logger;
     this.kernel = kernel;
 }
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="buildRepository"><see cref="IRepository{BuildReadModel}"/>.</param>
 /// <param name="distributionsRepository"><see cref="IReadOnlyRepository{DistributionReadModel}"/>.</param>
 /// <param name="mapper"><see cref="IMapper"/>.</param>
 /// <param name="mediator"><see cref="IMediator"/>.</param>
 public BuildEventsProjection(
     IRepository <BuildReadModel> buildRepository,
     IReadOnlyRepository <DistributionReadModel> distributionsRepository,
     IMapper mapper,
     IMediator mediator)
 {
     this.buildRepository         = buildRepository;
     this.distributionsRepository = distributionsRepository;
     this.mapper   = mapper;
     this.mediator = mediator;
 }
示例#52
0
 public CreateWalletCommandHandler(
     IUserContext userContext,
     IWalletRepository repository,
     IReadOnlyRepository <Currency> currencyRepository,
     IMapperDefinition <CreateWalletCommand, Wallet> walletMapper)
 {
     _userContext        = userContext ?? throw new ArgumentNullException(nameof(userContext));
     _repository         = repository ?? throw new ArgumentNullException(nameof(repository));
     _walletMapper       = walletMapper ?? throw new ArgumentNullException(nameof(walletMapper));
     _currencyRepository = currencyRepository ?? throw new ArgumentNullException(nameof(currencyRepository));
 }
 /// <summary>
 /// Create an instance of this Decorator.
 /// </summary>
 /// <param name="decoratedService">Object service that is being decorated.</param>
 /// <param name="readOnlyRepository">Read-only repository for data retrieval.</param>
 /// <param name="userContext">Contextual information on the current user.</param>
 /// <param name="logger">Logging service (optional).</param>
 /// <exception cref="ArgumentNullException">A mandatory parameter is null.</exception>
 public ObjectServiceAuditDecorator(
     IObjectService <TEntity, TKey> decoratedService,
     IReadOnlyRepository <TEntity, TKey> readOnlyRepository,
     IUserContext userContext,
     ILogger <ObjectServiceAuditDecorator <TEntity, TKey> > logger = null)
 {
     DecoratedService   = decoratedService ?? throw new ArgumentNullException(nameof(decoratedService));
     ReadOnlyRepository = readOnlyRepository ?? throw new ArgumentNullException(nameof(readOnlyRepository));
     UserContext        = userContext ?? throw new ArgumentNullException(nameof(userContext));
     Logger             = logger;
 }
示例#54
0
        private static void DumpPeople(IReadOnlyRepository <Person> employeeRepository)
        {
            //Covariance:
            //Take a type that uses Employee and treat it as if it is using Person.

            var employees = employeeRepository.FindAll();

            foreach (var employee in employees)
            {
                Console.WriteLine(employee.Name);
            }
        }
示例#55
0
 public AuthenticateCommandHandler(
     IUnitOfWork unitOfWork,
     IEnumerable <IValidator <AuthenticateCommand> > validators,
     IHashManager hashManager,
     IReadOnlyRepository <User> userReadOnlyRepository,
     IRSACryptoEngine cryptoEngine) :
     base(unitOfWork, validators)
 {
     _cryptoEngine           = cryptoEngine.ThrowIfNull(nameof(cryptoEngine));
     _userReadOnlyRepository = userReadOnlyRepository.ThrowIfNull(nameof(userReadOnlyRepository));
     _hashManager            = hashManager.ThrowIfNull(nameof(hashManager));
 }
示例#56
0
 public GetTokenDtoWorkerHandler(IMapper mapper,
                                 IReadOnlyRepository repository,
                                 IApplicationUserContext applicationUserContext,
                                 IComponentContext scope,
                                 ISecondaryExecutionPipeline executionPlan,
                                 IConfiguration configuration,
                                 IWorkerContext <ApplicationUserContext> context) : base(mapper, repository, scope, context)
 {
     _applicationUserContext = applicationUserContext;
     _executionPlan          = executionPlan;
     _configuration          = configuration;
 }
示例#57
0
 public GetLeadWorkerHandler(IMapper mapper,
                             IApplicationUserContext applicationUserContext,
                             IReadOnlyRepository repository,
                             IWorkerContext <GetLeadResponse> context,
                             IDelegateContext redisContext,
                             ILifetimeScope scope
                             )
     : base(mapper, repository, scope, context)
 {
     _applicationUserContext = applicationUserContext;
     _redisContext           = redisContext;
 }
示例#58
0
 private int getRights(Subject subject, Entity entity, long key, IReadOnlyRepository <EntityPermission> entityPermissionRepository)
 {
     if (subject == null)
     {
         return(entityPermissionRepository.Get(m => m.Subject == null && m.Entity.Id == entity.Id && m.Key == key).FirstOrDefault()?.Rights ?? 0);
     }
     if (entity == null)
     {
         return(0);
     }
     return(entityPermissionRepository.Get(m => m.Subject.Id == subject.Id && m.Entity.Id == entity.Id && m.Key == key).FirstOrDefault()?.Rights ?? 0);
 }
示例#59
0
 public CreatePortfolioStgWorkerHandler(
     IMapper mapper,
     IReadOnlyRepository repository,
     ILifetimeScope scope,
     ILog logger,
     ISecondaryExecutionPipeline secondaryExecutionPipeline,
     IWorkerContext <ImportXlsPipelineResponse> context)
     : base(mapper, repository, scope, context)
 {
     _logger = logger;
     _secondaryExecutionPipeline = secondaryExecutionPipeline;
 }
示例#60
0
 public UserModule(IReadOnlyRepository readOnlyRepository)
 {
     Get["/users/byEmail/{email}"] =
         p =>
         {
             var email = (string) p.email;
             IEnumerable<User> users = readOnlyRepository.Query<User>(x => x.Email.Contains(email));
             List<UserSearchResult> userSearchResults =
                 users.Select(x => new UserSearchResult {Name = x.Name, UserId = x.Id}).ToList();
             return new UserSearchResultsResponse(userSearchResults);
         };
 }