Exemplo n.º 1
0
        public AppUserModelService(IUserApiService userApiService, ILogger logger, IAppSettings appSettings)
        {
            _favouriteCakes = new SourceCache <CakeDto, int>(c => c.Id);
            _appSettings    = appSettings;
            _userIdSubject  = new BehaviorSubject <string>(String.Empty);
            _userSubject    = new BehaviorSubject <UserDto>(null);
            _cd             = new CompositeDisposable();

            _favouriteCakes
            .Connect()
            .CacheChangeSet(CacheKey, logger)
            .Subscribe();

            _userIdSubject
            .ObserveOn(RxApp.TaskpoolScheduler)
            .Where(u => u != null)
            .SelectMany(async uId => await userApiService.GetFavourites(uId))
            .RetryWithBackoff(3)
            .LogException(logger)
            .Subscribe(cakes =>
            {
                _favouriteCakes.Edit(l => l.AddOrUpdate(cakes));
            })
            .DisposeWith(_cd);

            Observable.FromAsync(async() => await _favouriteCakes.FromCache(CacheKey, EqualityComparer <CakeDto> .Default)).Subscribe().DisposeWith(_cd);
        }
 public ApiAuthenticationService(IHttpContextAccessor httpContextAccessor,
                                 ICustomerService customerService, IUserApiService userApiService)
 {
     _httpContextAccessor = httpContextAccessor;
     _customerService     = customerService;
     _userApiService      = userApiService;
 }
Exemplo n.º 3
0
        public BakerProfileViewModel(
            string bakerId,
            IScreen hostScreen = null,
            ICakeModelService cakeModelService       = null,
            IAppUserModelService appUserModelService = null,
            IBakerModelService bakerModelService     = null,
            IUserApiService userApiService           = null,
            ILogger logger = null,
            IMapper mapper = null) : base(hostScreen)
        {
            _cakeModelService    = cakeModelService;
            _appUserModelService = appUserModelService;
            _bakerModelService   = bakerModelService;
            _userApiService      = userApiService;
            _logger = logger;
            _mapper = mapper;

            _bakerIdSubject = new Subject <string>();

            StartChatCommand = ReactiveCommand.CreateFromTask(GoToChat);
            PrepareCommand   = ReactiveCommand.CreateFromTask(async b => await Prepare(bakerId));

            Observable.Return(Unit.Default)
            .InvokeCommand(PrepareCommand);

            PrepareCommand.Subscribe();
        }
Exemplo n.º 4
0
 public CreateUserCommandHandler(IHotelDbContext context, IMapper mapper, IUserApiService service, IDateTime dateTime)
 {
     this.context  = context;
     this.mapper   = mapper;
     this.service  = service;
     this.dateTime = dateTime;
 }
 public MessageService(
     IHttpClientFactory httpClientFactory,
     IUserApiService userApiService
     ) : base(httpClientFactory)
 {
     _userApiService = userApiService;
 }
Exemplo n.º 6
0
 public ApiAuthenticationService(ApiConfig apiConfig, IHttpContextAccessor httpContextAccessor,
                                 ICustomerService customerService, IUserApiService userApiService)
 {
     this._apiConfig           = apiConfig;
     this._httpContextAccessor = httpContextAccessor;
     this._customerService     = customerService;
     this._userApiService      = userApiService;
 }
 public UserController(IQueryHandler queryHandler, ILogger <UserController> logger,
                       IUserApiService userApiService, IUserApiClient userApiClient, IConfiguration config)
 {
     _queryHandler   = queryHandler;
     _logger         = logger;
     _userApiService = userApiService;
     _userApiClient  = userApiClient;
     _config         = config;
 }
 public AllocationService(ICommandHandler commandHandler, IQueryHandler queryHandler,
                          ILogger <AllocationService> logger,
                          IConfiguration config, IUserApiService userApiService)
 {
     _commandHandler = commandHandler;
     _queryHandler   = queryHandler;
     _logger         = logger;
     _config         = config;
     _userApiService = userApiService;
 }
Exemplo n.º 9
0
 public FriendService(IMapper mapper,
                      IActivityStatusRepository activityStatusRepository,
                      IFriendRelationshipRepository friendRelationshipRepository,
                      IFriendRequestRepository friendRequestRepository,
                      IUserApiService userApiService
                      )
 {
     _mapper = mapper;
     _activityStatusRepository     = activityStatusRepository;
     _friendRelationshipRepository = friendRelationshipRepository;
     _friendRequestRepository      = friendRequestRepository;
     _userApiService = userApiService;
 }
 public HubClientService(
     IAccessTokenProvider tokenProvider,
     NavigationManager navigationManager,
     IGroupService groupService,
     IUserApiService userApiService,
     IMessageService messagesService)
 {
     _tokenProvider     = tokenProvider;
     _navigationManager = navigationManager;
     _groupService      = groupService;
     _userApiService    = userApiService;
     _messagesService   = messagesService;
 }
Exemplo n.º 11
0
 public MessageService(IMapper mapper,
                       IActivityStatusRepository activityStatusRepository,
                       IUserApiService userApiService,
                       IMessageRepository messageRepository,
                       IConversationRepository conversationRepository,
                       IParticipantRepository participantRepository
                       )
 {
     _mapper = mapper;
     _activityStatusRepository = activityStatusRepository;
     _userApiService           = userApiService;
     _messageRepository        = messageRepository;
     _conversationRepository   = conversationRepository;
     _participantRepository    = participantRepository;
 }
Exemplo n.º 12
0
 public void Setup()
 {
     CommandHandler   = new Mock <ICommandHandler>();
     QueryHandler     = new Mock <IQueryHandler>();
     AllocationLogger = new Mock <ILogger <AllocationService> >();
     Configuration    = new Mock <IConfiguration>();
     GroupsConfig     = new Mock <IOptions <UserGroupsConfiguration> >();
     SetMockGroups();
     SetMockConfig();
     MockUserApiService = new Mock <IUserApiService>();
     UserApiClient      = new Mock <IUserApiClient>();
     UserApiLogger      = new Mock <ILogger <TestApi.Services.Services.UserApiService> >();
     UserApiService     = new TestApi.Services.Services.UserApiService(UserApiClient.Object, GroupsConfig.Object, UserApiLogger.Object);
     AllocationService  = new AllocationService(CommandHandler.Object, QueryHandler.Object, AllocationLogger.Object,
                                                Configuration.Object, MockUserApiService.Object);
 }
Exemplo n.º 13
0
        public DisclaimerViewModel(
            DisclaimerNavigation parameter,
            IScreen hostScreen = null,
            IAppUserModelService appUserModelService = null,
            IUserApiService userApiService           = null,
            Serilog.ILogger logger = null) : base(hostScreen)
        {
            _hostScreen          = hostScreen;
            _appUserModelService = appUserModelService ?? Locator.Current.GetService <IAppUserModelService>();
            _userApiService      = userApiService ?? Locator.Current.GetService <IUserApiService>();
            _logger = logger ?? Locator.Current.GetService <Serilog.ILogger>();

            AcceptCommand = ReactiveCommand.CreateFromTask(Accept);
            RejectCommand = ReactiveCommand.CreateFromTask(Reject);

            Prepare(parameter);
        }
Exemplo n.º 14
0
        public LoginValidator(
            IEnumerable <IValidatorConsumer <LoginModel> > validators,
            ApiConfig apiConfig, ICustomerService customerService, IUserApiService userApiService, IEncryptionService encryptionService)
            : base(validators)
        {
            if (!apiConfig.Enabled)
            {
                RuleFor(x => x).Must((x) => false).WithMessage("API is disabled");
            }

            RuleFor(x => x.Email).NotEmpty().WithMessage("Email is required");
            RuleFor(x => x.Password).NotEmpty().WithMessage("Password is required");
            RuleFor(x => x).MustAsync(async(x, context) =>
            {
                if (!string.IsNullOrEmpty(x.Email))
                {
                    var userapi = await userApiService.GetUserByEmail(x.Email.ToLowerInvariant());
                    if (userapi != null && userapi.IsActive)
                    {
                        var base64EncodedBytes = System.Convert.FromBase64String(x.Password);
                        var password           = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
                        if (userapi.Password == encryptionService.EncryptText(password, userapi.PrivateKey))
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }).WithMessage(("User not exists or password is wrong"));
            RuleFor(x => x).MustAsync(async(x, context) =>
            {
                if (!string.IsNullOrEmpty(x.Email))
                {
                    var customer = await customerService.GetCustomerByEmail(x.Email.ToLowerInvariant());
                    if (customer != null && customer.Active && !customer.IsSystemAccount)
                    {
                        return(true);
                    }
                }
                return(false);
            }).WithMessage("Customer not exist");
        }
Exemplo n.º 15
0
 public UsersController(
     IJsonFieldsSerializer jsonFieldsSerializer,
     IAclService aclService,
     IUserService userService,
     ITenantMappingService tenantMappingService,
     ITenantService tenantService,
     IUserActivityService userActivityService,
     IUserApiService userApiService,
     IGenericAttributeService genericAttributeService,
     IEncryptionService encryptionService,
     IStoreService storeService,
     IFactory <User> factory)
     : base(jsonFieldsSerializer, aclService, userService, tenantMappingService, tenantService, userActivityService)
 {
     _userApiService          = userApiService;
     _genericAttributeService = genericAttributeService;
     _encryptionService       = encryptionService;
     _storeService            = storeService;
     _factory = factory;
 }
Exemplo n.º 16
0
        public LoginViewModel(
            IScreen hostScreen = null,
            IAccountApiService accountApiService     = null,
            IDialogService dialogService             = null,
            IAppUserModelService appUserModelService = null,
            IUserApiService userApiService           = null,
            ILogger logger = null)
        {
            _accountApiService   = accountApiService ?? Locator.Current.GetService <IAccountApiService>();
            _dialogService       = dialogService ?? Locator.Current.GetService <IDialogService>();
            _appUserModelService = appUserModelService ?? Locator.Current.GetService <IAppUserModelService>();
            _userApiService      = userApiService ?? Locator.Current.GetService <IUserApiService>();
            _logger = logger ?? Locator.Current.GetService <ILogger>();

            GoToRegisterCommand = ReactiveCommand.CreateFromTask(GoToRegister);

            var validateLoginDetailsObservable = this.WhenAnyValue(vm => vm.Username, vm => vm.Password,
                                                                   (un, pw) => SetIsUsernameValid(un) && SetIsPasswordValid(pw)).StartWith(false);

            validateLoginDetailsObservable.ToProperty(this, vm => vm.CanSubmit, out _canSubmitPropertyHelper);

            LoginCommand = ReactiveCommand.CreateFromTask(Login, validateLoginDetailsObservable);
        }
Exemplo n.º 17
0
 public UsersController(IUserApiService userAPIService, IUserPersistenceService userService, ILogger <UsersController> logger)
 {
     _userApiService = userAPIService;
     _userService    = userService;
     _logger         = logger;
 }
Exemplo n.º 18
0
 public ApiUserController(IUserApiService userApiService, IEncryptionService encryptionService)
 {
     this._userApiService    = userApiService;
     this._encryptionService = encryptionService;
 }
Exemplo n.º 19
0
 public UIController(IUserApiService userApiService)
 {
     _apiPath        = "http://localhost:37266/api";
     _client         = new HttpClient();
     _userApiService = userApiService;
 }
Exemplo n.º 20
0
 public TokenController(IMediator mediator, IUserApiService userApiService)
 {
     _userApiService = userApiService;
     _mediator       = mediator;
 }
Exemplo n.º 21
0
 public UserHandler(IUserApiService userService)
 {
     this.userService = userService;
 }
Exemplo n.º 22
0
 public WebHookEventConsumer()
 {
     _userApiService = EngineContext.Current.Resolve <IUserApiService>();
     _dtoHelper      = EngineContext.Current.Resolve <IDtoHelper>();
 }
 public JwtBearerAuthenticationService(
     ICustomerService customerService, IUserApiService userApiService)
 {
     _customerService = customerService;
     _userApiService  = userApiService;
 }
Exemplo n.º 24
0
 public UserApiController(IUserApiService userApiService)
 {
     _userApiService = userApiService;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Create a controller and set the service
 /// </summary>
 public UserApiController(IUserApiService service)
 {
     _service = service;
 }
Exemplo n.º 26
0
 public HomeController(ILogger <HomeController> logger, IAuthService authService, IUserApiService userApiService)
 {
     _authService    = authService;
     _userApiService = userApiService;
 }