private void AddUserToDatabase(User user) { var followerCount = api.Helix.Users.GetUsersFollowsAsync(null, null, 1, null, user.Id).Result.TotalFollows; var isPartner = user.BroadcasterType.Equals("partner"); Channel channel = new Channel() { Id = user.Id, Username = user.Login, Displayname = user.DisplayName, Views = user.ViewCount, AmountFollowers = followerCount, IsPartner = isPartner, TwitterHandle = "none", InstagramHandle = "none", DiscordHandle = "none", ContactMail = "none", IsCommunityChannel = false, CommunityStreamers = user.DisplayName, IsEnabled = false, Bio = user.Description }; _channelService.CreateChannel(channel); client.SendMessage(TwitchInfo.BotName, $"Added {user.Login} to the database."); }
private void CreateChannelRequestHandler(NetworkClient client, Message message) { var channelToCreate = message.GetData <Channel>(); var createdChannel = channelService.CreateChannel(channelToCreate.Name); var createdChannelSession = new ChannelSession(createdChannel); AddChannel(createdChannelSession); BroadcastAll(client, Message.Create(MessageType.CreateChannelResponse, createdChannelSession), true); }
public ActionResult Create(ChannelCreate model) { if (ModelState.IsValid) { var service = new ChannelService(); service.CreateChannel(model); return(RedirectToAction("Create")); } return(View(model)); }
public static async Task Initialize(IServiceProvider serviceProvider) { using (var context = new ActiveBearContext( serviceProvider.GetRequiredService <DbContextOptions <ActiveBearContext> >())) { var userService = new UserService(context); var channelService = new ChannelService(context); // Look for any messages. if (context.Channels.Any()) { return; // DB has been seeded } // Create Users var userOne = await userService.CreateUser("UserOne", "abcdefg", "The first user."); var userTwo = await userService.CreateUser("UserTwo", "qwerty", "The second user."); // Create channels var channel = await channelService.CreateChannel("Public", "general", userOne); var channelTwo = await channelService.CreateChannel("SecretRoom", "starcraft", userTwo); } }
// Attempt to create a new channel from the given data public async Task CreateChannel(string channelCreationPacket) { try { var packet = JsonConvert.DeserializeObject <ChannelCreationPacket>(channelCreationPacket); var user = await userService.ExistingUser(packet.UserCookie); Channel channel = await channelService.CreateChannel( packet.ChannelTitle, packet.ChannelKey, user); if (channel != null) { await Clients.Caller.ChannelCreated(channel.Id); } // TODO - return error if channel or user is null } catch { return; } }
protected async Task SetUp() { context = DbService.NewTestContext(); userService = new UserService(context); channelService = new ChannelService(context); messageService = new MessageService(context); authService = new ChannelAuthService(context); user = await userService.ExistingUser(Lorem); if (user == null) { user = await userService.CreateUser(Lorem, Lorem, Lorem); } channel = await channelService.CreateChannel(Lorem, Lorem, user); packet = JsonConvert.SerializeObject(new MessagePacket { UserCookie = user.CookieId, Channel = channel.Id, Message = Lorem }); }