public LobbyServices(IUsersStore usersStore, GameBuildersCache gameBuildersCache, UsersCache usersCache, Func <User, string, Player> playerResolver) { _gameBuildersCache = gameBuildersCache; _usersStore = usersStore; _usersCache = usersCache; _playerResolver = playerResolver; }
public UserModule(IUsersStore userStore, IEventStore eventStore) : base("/users") { _userStore = userStore; Post("/", _ => { var newUser = this.Bind <LoyalProgramUser>(); AddRegisteredUser(newUser); eventStore.PutEvent("UserAdded", newUser); return(CreatedResponse(newUser)); }); Put("/{userId:int}", parameter => { int userId = parameter.userId; var updatedUser = this.Bind <LoyalProgramUser>(); _userStore.UpdateUser(userId, updatedUser); eventStore.PutEvent("UserUpdated", updatedUser); return(updatedUser); }); Get("/{userId:int}", parameter => { var userId = parameter.userId; var user = _userStore.GetUser(userId); return(user != null ? user : HttpStatusCode.NotFound); }); }
public OrderType(IDataLoaderContextAccessor accessor, IUsersStore users, IOrdersStore orders) { Name = "Order"; Field(x => x.OrderId); Field(x => x.OrderedOn); Field <UserType, User>() .Name("User") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, User>("GetUsersById", users.GetUsersByIdAsync); return(loader.LoadAsync(ctx.Source.UserId)); }); Field <ListGraphType <OrderItemType>, IEnumerable <OrderItem> >() .Name("Items") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddCollectionBatchLoader <int, OrderItem>("GetOrderItemsById", orders.GetItemsByOrderIdAsync); return(loader.LoadAsync(ctx.Source.OrderId)); }); }
/// <summary> /// Initializes a new instance of the <see cref="UsersManager"/> class /// </summary> /// <param name="usersStore">Users store</param> /// <param name="pushNotificationsManager">Push notifications manager</param> /// <param name="popularUsersManager">Popular users manager</param> /// <param name="searchQueue">Search queue</param> public UsersManager(IUsersStore usersStore, IPushNotificationsManager pushNotificationsManager, IPopularUsersManager popularUsersManager, ISearchQueue searchQueue) { this.usersStore = usersStore; this.popularUsersManager = popularUsersManager; this.pushNotificationsManager = pushNotificationsManager; this.searchQueue = searchQueue; }
public TransactionSummaryBuilder(ITransactionStore transactionStore, IUsersStore usersStore, ITransactionsImporter transactionsImporter) { this.transactionStore = transactionStore; this.usersStore = usersStore; this.transactionsImporter = transactionsImporter; }
/// <summary> /// Initializes a new instance of the <see cref="PopularTopicsManager"/> class /// </summary> /// <param name="topicsStore">Topics store</param> /// <param name="usersStore">Users store</param> /// <param name="appsStore">Apps store</param> public PopularTopicsManager( ITopicsStore topicsStore, IUsersStore usersStore, IAppsStore appsStore) { this.topicsStore = topicsStore; this.usersStore = usersStore; this.appsStore = appsStore; }
public BanHostedService( IUsersStore usersStore, ILogger <BanHostedService> logger, ITelegramBotClient telegramBot) { _usersStore = usersStore; _logger = logger; _telegramBot = telegramBot; }
public WelcomeService( AppSettings settings, IUsersStore usersStore, ILogger <WelcomeService> logger, ITelegramBotClient telegramBot) { _settings = settings; _usersStore = usersStore; _logger = logger; _telegramBot = telegramBot; }
public TransactionsImporter(ITransactionStore transactionsStore, IBankDataProvider bankDataProvider, IOptionsMonitor <DataImportOptions> dataImportOptions, IClock clock, IUsersStore usersStore) { this.transactionsStore = transactionsStore; this.bankDataProvider = bankDataProvider; this.clock = clock; this.usersStore = usersStore; this.dataImportOptions = dataImportOptions.CurrentValue; }
public static User CreateComputer(this IUsersStore store) { Interlocked.Increment(ref lastNumber); return(new User() { Id = Guid.NewGuid().ToString(), Name = $"Computer #{lastNumber}", Money = 250, IsHuman = false }); }
public QueryType(IDataLoaderContextAccessor accessor, IUsersStore users, IOrdersStore orders) { Name = "Query"; Field <ListGraphType <UserType>, IEnumerable <User> >() .Name("Users") .Description("Get all Users") .Returns <IEnumerable <User> >() .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddLoader("GetAllUsers", users.GetAllUsersAsync); return(loader.LoadAsync()); }); Field <ListGraphType <UserType>, IEnumerable <User> >() .Name("UsersWithDelay") .Description("Get all Users") .Returns <IEnumerable <User> >() .ResolveAsync(async ctx => { await System.Threading.Tasks.Task.Delay(20); var loader = accessor.Context.GetOrAddLoader("GetAllUsersWithDelay", users.GetAllUsersAsync); return(loader.LoadAsync()); }); Field <OrderType, Order>() .Name("Order") .Description("Get Order by ID") .Argument <NonNullGraphType <IntGraphType> >("orderId", "") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, Order>("GetOrderById", orders.GetOrderByIdAsync, x => x.OrderId); return(loader.LoadAsync(ctx.GetArgument <int>("orderId"))); }); Field <ListGraphType <OrderType>, IEnumerable <Order> >() .Name("Orders") .Description("Get all Orders") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddLoader("GetAllOrders", orders.GetAllOrdersAsync); return(loader.LoadAsync()); }); }
public static User CreateUser(this IUsersStore store, ClaimsPrincipal current) { var user = new User() { Id = current.GetId(), Name = current.Identity.Name, AvatarUrl = current.FindFirst("Photo").Value, Money = 250, IsHuman = true }; return(user); }
public static User RegisterAsGuest(this IUsersStore store, string connectionId) { Interlocked.Increment(ref lastNumber); var user = new User() { Id = Guid.NewGuid().ToString(), Name = $"Guest #{lastNumber}", Money = 250, IsHuman = true }; return(user); }
/// <summary> /// Initializes a new instance of the <see cref="LikesManager"/> class /// </summary> /// <param name="likesStore">Likes store</param> /// <param name="topicsStore">Topics store</param> /// <param name="usersStore">Users store</param> /// <param name="likesQueue">Likes queue</param> /// <param name="fanoutActivitiesQueue"><c>Fanout</c> activities queue</param> /// <param name="popularTopicsManager">Popular topics manager</param> /// <param name="notificationsManager">Notifications manager</param> public LikesManager( ILikesStore likesStore, ITopicsStore topicsStore, IUsersStore usersStore, ILikesQueue likesQueue, IFanoutActivitiesQueue fanoutActivitiesQueue, IPopularTopicsManager popularTopicsManager, INotificationsManager notificationsManager) { this.likesStore = likesStore; this.topicsStore = topicsStore; this.usersStore = usersStore; this.likesQueue = likesQueue; this.fanoutActivitiesQueue = fanoutActivitiesQueue; this.popularTopicsManager = popularTopicsManager; this.notificationsManager = notificationsManager; }
public GameContext(Player[] players, Guid gameId, Func <ComputerBrain> computerBrain, Func <GameResult> gameResultResolve, IUsersStore usersStore) { Table = Enumerable.Range(0, 4).Select(suit => new bool[15]).ToArray(); Id = gameId; Players = players; _computerBrain = computerBrain; _gameResultResolve = gameResultResolve; _usersStore = usersStore; BankMoney = 150; foreach (var p in Players) { p.Money -= 50; p.Lobby.RefreshMoney(p.Money); _usersStore.UpdateMoney(p); } SetFirstPlayer(); }
public UsersActivity(IReactionHubProxy reactionHubProxy, IUsersStore usersStore) { this.ReactionHubProxy = reactionHubProxy; this.UsersStore = usersStore; this.ReactionHubProxy.Connected += () => { this.ReactionHubProxy .OnReceiveReaction() .Subscribe(x => { var user = this.SelectedUser.Value; if (user == null) { return; } lock ( user ) { switch (x.Item1) { case Models.eReactionType.Good: user.GoodCount++; break; case Models.eReactionType.Nice: user.NiceCount++; break; case Models.eReactionType.Fun: user.FunCount++; break; } } }) .AddTo(this.Disposable); }; this.SelectedUser = new ReactivePropertySlim <IUser>(); this.Users = new ReactiveCollection <IUser>(); this.Load(); }
public GameService(GamesCache gameCache, IUsersStore userStore, UsersCache usersCache) { _gameCache = gameCache; _userStore = userStore; _usersCache = usersCache; }
public UsersController(IUsersStore usersStore) { _usersStore = usersStore; }
public QueryType(IDataLoaderContextAccessor accessor, IUsersStore users, IOrdersStore orders) { Name = "Query"; Field <ListGraphType <UserType>, IEnumerable <User> >() .Name("Users") .Description("Get all Users") .Returns <IEnumerable <User> >() .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddLoader("GetAllUsers", users.GetAllUsersAsync); return(loader.LoadAsync()); }); Field <ListGraphType <UserType>, IEnumerable <User> >() .Name("UsersWithDelay") .Description("Get all Users") .Returns <IEnumerable <User> >() .ResolveAsync(async ctx => { await System.Threading.Tasks.Task.Delay(20); var loader = accessor.Context.GetOrAddLoader("GetAllUsersWithDelay", users.GetAllUsersAsync); return(loader.LoadAsync()); }); Field <OrderType, Order>() .Name("Order") .Description("Get Order by ID") .Argument <NonNullGraphType <IntGraphType> >("orderId", "") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, Order>("GetOrderById", orders.GetOrderByIdAsync, x => x.OrderId); return(loader.LoadAsync(ctx.GetArgument <int>("orderId"))); }); Field <ListGraphType <OrderType>, IEnumerable <Order> >() .Name("Orders") .Description("Get all Orders") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddLoader("GetAllOrders", orders.GetAllOrdersAsync); return(loader.LoadAsync()); }); Field <NonNullGraphType <ListGraphType <UserType> >, IEnumerable <IDataLoaderResult <User> > >() .Name("SpecifiedUsers") .Description("Get Users by ID") .Argument <NonNullGraphType <ListGraphType <NonNullGraphType <IntGraphType> > > >("ids") .Resolve(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, User>("GetUserById", users.GetUsersByIdAsync); var ids = ctx.GetArgument <IEnumerable <int> >("ids"); var ret = ids.Select(id => loader.LoadAsync(id)); return(ret); }); Field <NonNullGraphType <ListGraphType <NonNullGraphType <ListGraphType <NonNullGraphType <IntGraphType> > > > > >() .Name("ExerciseListsOfLists") .Argument <ListGraphType <ListGraphType <IntGraphType> > >("values") .Resolve(ctx => { var ret = ctx.GetArgument <IEnumerable <IEnumerable <int?> > >("values"); //new int?[][] { new int?[] { 1, 2 }, new int?[] { 4, 5, 6 } }; var ret2 = ret.Select(x => new SimpleDataLoader <IEnumerable <SimpleDataLoader <int?> > >(_ => Task.FromResult(x.Select(y => new SimpleDataLoader <int?>(_ => Task.FromResult(y)))))); return(ret2); }); }
public WelcomeService(IUsersStore usersStore, ILogger <WelcomeService> logger, ITelegramBotClient telegramBot) { _usersStore = usersStore; _logger = logger; _telegramBot = telegramBot; }
public MultiUsersViewModel(IUsersActivity usersActivity, IUsersStore usersStore, IThemeService themeService, IStatusService statusService) { this.UsersActivity = usersActivity; this.UserStore = usersStore; this.ThemeService = themeService; this.StatusService = statusService; this.NewUserName = new ReactiveProperty <string>(); this.SelectedUser = this.UsersActivity .SelectedUser .ToReactivePropertyAsSynchronized(x => x.Value) .AddTo(this.Disposable); this.Users = this.UsersActivity .Users .ToReadOnlyReactiveCollection() .AddTo(this.Disposable); this.FilePath = this.UserStore .ToReactivePropertyAsSynchronized(x => x.FilePath) .AddTo(this.Disposable); this.AddUserCommand = this.NewUserName .Select(x => !string.IsNullOrWhiteSpace(x)) .ToReactiveCommand() .AddTo(this.Disposable); this.RemoveUserCommand = this.SelectedUser .Select(x => x != null) .ToReactiveCommand() .AddTo(this.Disposable); this.UnselectCommand = this.SelectedUser .Select(x => x != null) .ToReactiveCommand() .AddTo(this.Disposable); this.ResetUserCount = this.SelectedUser .Select(x => x != null) .ToReactiveCommand() .AddTo(this.Disposable); this.SaveCommand = this.FilePath .Select(x => !string.IsNullOrWhiteSpace(x)) .ToReactiveCommand() .AddTo(this.Disposable); this.LoadCommand = this.FilePath .Select(x => !string.IsNullOrWhiteSpace(x)) .ToReactiveCommand() .AddTo(this.Disposable); this.AddUserCommand .Subscribe(_ => { this.UsersActivity.AddUser(this.NewUserName.Value); this.NewUserName.Value = string.Empty; }); this.RemoveUserCommand .Subscribe(_ => { this.UsersActivity.RemoveUser(this.SelectedUser.Value); this.SelectedUser.Value = null; }); this.UnselectCommand .Subscribe(_ => { this.SelectedUser.Value = null; }); this.ResetUserCount .Subscribe(_ => { this.UsersActivity.CountReset(); }); this.SaveCommand .Subscribe(_ => { this.UsersActivity.Save(); }); this.LoadCommand .Subscribe(_ => { this.UsersActivity.Load(); }); this.SelectedUser .Select(x => x != null) .Subscribe(x => { this.ThemeService.IsBusy = x; }) .AddTo(this.Disposable); this.SelectedUser .Select(x => x != null ? $"発表者:{x.Name}" : "準備完了") .Subscribe(x => { this.StatusService.SetStatus(x); }) .AddTo(this.Disposable); this.Title.Value = "Multi Users"; }
public QueryType(IDataLoaderContextAccessor accessor, IUsersStore users, IOrdersStore orders) { Name = "Query"; Field <ListGraphType <UserType>, IEnumerable <User> >() .Name("Users") .Description("Get all Users") .Returns <IEnumerable <User> >() .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddLoader("GetAllUsers", users.GetAllUsersAsync); return(loader.LoadAsync()); }); Field <ListGraphType <UserType>, IEnumerable <User> >() .Name("UsersWithDelay") .Description("Get all Users") .Returns <IEnumerable <User> >() .ResolveAsync(async ctx => { await System.Threading.Tasks.Task.Delay(20).ConfigureAwait(false); var loader = accessor.Context.GetOrAddLoader("GetAllUsersWithDelay", users.GetAllUsersAsync); return(loader.LoadAsync()); }); Field <OrderType, Order>() .Name("Order") .Description("Get Order by ID") .Argument <NonNullGraphType <IntGraphType> >("orderId", "") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, Order>("GetOrderById", orders.GetOrderByIdAsync, x => x.OrderId); return(loader.LoadAsync(ctx.GetArgument <int>("orderId"))); }); Field <ListGraphType <OrderType>, IEnumerable <Order> >() .Name("Orders") .Description("Get all Orders") .ResolveAsync(ctx => { var loader = accessor.Context.GetOrAddLoader("GetAllOrders", orders.GetAllOrdersAsync); return(loader.LoadAsync()); }); Field <NonNullGraphType <ListGraphType <UserType> >, IEnumerable <IDataLoaderResult <User> > >() .Name("SpecifiedUsers") .Description("Get Users by ID") .Argument <NonNullGraphType <ListGraphType <NonNullGraphType <IntGraphType> > > >("ids") .Resolve(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, User>("GetUserById", users.GetUsersByIdAsync); var ids = ctx.GetArgument <IEnumerable <int> >("ids"); var ret = ids.Select(id => loader.LoadAsync(id)); return(ret); }); Field <NonNullGraphType <ListGraphType <UserType> >, IDataLoaderResult <IEnumerable <User> > >() .Name("SpecifiedUsersWithThen") .Description("Get Users by ID skipping null matches") .Argument <NonNullGraphType <ListGraphType <NonNullGraphType <IntGraphType> > > >("ids") .Resolve(ctx => { var loader = accessor.Context.GetOrAddBatchLoader <int, User>("GetUserById", users.GetUsersByIdAsync); var ids = ctx.GetArgument <IEnumerable <int> >("ids"); // note: does not work properly without ToList, because LoadAsync would not have // been called, so the ids would not have been queued for execution prior to the // first call to GetResultAsync var ret = ids.Select(id => loader.LoadAsync(id)).ToList(); var ret2 = ret.Then(values => values.Where(x => x != null)); return(ret2); }); Field <NonNullGraphType <ListGraphType <NonNullGraphType <ListGraphType <NonNullGraphType <IntGraphType> > > > > >() .Name("ExerciseListsOfLists") .Argument <ListGraphType <ListGraphType <IntGraphType> > >("values") .Resolve(ctx => { var ret = ctx.GetArgument <IEnumerable <IEnumerable <int?> > >("values"); //new int?[][] { new int?[] { 1, 2 }, new int?[] { 4, 5, 6 } }; var ret2 = ret.Select(x => new SimpleDataLoader <IEnumerable <SimpleDataLoader <int?> > >(_ => Task.FromResult(x.Select(y => new SimpleDataLoader <int?>(_ => Task.FromResult(y)))))); return(ret2); }); }
/// <summary> /// Initializes a new instance of the <see cref="PopularUsersManager"/> class /// </summary> /// <param name="usersStore">Users store</param> public PopularUsersManager(IUsersStore usersStore) { this.usersStore = usersStore; }
public UsersRepository(IUsersStore context) { this.Context = context; }
public UserController(IUsersStore usersStore) { this.usersStore = usersStore; }