partial void AddBuildingFields(ISubscriptionService <Building> subscriptionService) { FieldAsync <MutationResponseType <Building, BuildingType> >( "addBuilding", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <GuidGraphType> > { Name = "gamesessionId" }, new QueryArgument <NonNullGraphType <BuildingInputType> > { Name = "building" } ), resolve: async context => { var building = context.GetArgument <Building>("building"); var gamesessionId = context.GetArgument <Guid>("gamesessionId"); building.Id = Guid.NewGuid(); building.GamesessionIds.Add(gamesessionId); return(await subscriptionService.Add(building)); } ); FieldAsync <MutationResponseType <Building, BuildingType> >( "updateBuilding", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <BuildingInputType> > { Name = "building" } ), resolve: async context => { return(await subscriptionService.Update( context.GetArgument <Building>("building") )); } ); FieldAsync <MutationResponseType <Building, BuildingType> >( "deleteBuilding", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <GuidGraphType> > { Name = "id" } ), resolve: async context => { return(await subscriptionService.Delete( context.GetArgument <Guid>("id") )); } ); }
public IActionResult OnPostSubscribe(string email) { if (!string.IsNullOrEmpty(email)) { subscriptionService.Add(email); return(RedirectToPage("Confirmation", "Subscription")); } ErrorMessage = "Please enter email"; return(Page()); }
public override async Task Subscribe( IAsyncStreamReader <SubscriptionRequest> requestStream, IServerStreamWriter <SubscriptionReply> replyStream, ServerCallContext context) { await requestStream.MoveNext(); int userId = requestStream.Current.UserId; _subscriptionService.Add(userId, requestStream, replyStream); await Recover(userId, replyStream); await Listen(requestStream); }
public IActionResult OnPostSubscribe(string email) { if (!string.IsNullOrEmpty(email)) { var currentEmail = subscriptionService.GetByEmail(email); if (currentEmail == null) { subscriptionService.Add(email); return(RedirectToPage("Confirmation", "Subscribe")); } ErrorMessage = "User already exists"; return(Page()); } ErrorMessage = "Please enter email"; return(Page()); }
public async Task Subscribe(string topic) { var subscription = await _subscriptionService.Get(Context.ConnectionId); if (subscription != null) { await Groups.RemoveFromGroupAsync(Context.ConnectionId, subscription.Topic); await _subscriptionService.Delete(Context.ConnectionId); } await _subscriptionService.Add(new Subscription { Topic = topic, SubscriptionId = Context.ConnectionId }); await Groups.AddToGroupAsync(Context.ConnectionId, topic); var messages = await _messageService.GetByTopicName(topic); await Clients.Caller.SendAsync("connect", messages.ToJson()); }
partial void AddGamesessionFields( ISubscriptionService <Gamesession> subscriptionService, IAlternativesRepository <Inheritance> inheritancesRepository, IAlternativesRepository <Road> roadsRepository, IAlternativesRepository <Livingcondition> livingconditionsRepository ) { FieldAsync <MutationResponseType <Gamesession, GamesessionType> >( "addGamesession", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "userId" } ), resolve: async context => { var userId = context.GetArgument <string>("userId"); var gamesession = new Gamesession { OwnerId = userId }; gamesession.UserIds.Add(userId); //gamesession.Roads = await roadsRepository.GetAsync(gamesession.Id); //gamesession.Inheritances = await inheritancesRepository.GetAsync(gamesession.Id); //gamesession.Livingconditions = await livingconditionsRepository.GetAsync(gamesession.Id); return(await subscriptionService.Add(gamesession)); } ); FieldAsync <MutationResponseType <Gamesession, GamesessionType> >( "updateGamesession", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <GamesessionInputType> > { Name = "gamesession" } ), resolve: async context => { return(await subscriptionService.Update( context.GetArgument <Gamesession>("gamesession") )); } ); FieldAsync <MutationResponseType <Gamesession, GamesessionType> >( "deleteGamesession", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <GuidGraphType> > { Name = "id" } ), resolve: async context => { return(await subscriptionService.Delete( context.GetArgument <Guid>("id") )); } ); }