public async Task <IActionResult> NewChannel(ChatGroupModel channel) { var newChannelId = await groups.CreateChannel(channel.ToChatGroupChannel()); if (!String.IsNullOrWhiteSpace(newChannelId)) { return(Redirect($"/group/{channel.GroupId}/{newChannelId}")); } return(View()); }
public async Task AddToGroup(string groupName) { await Groups.AddToGroupAsync(Context.ConnectionId, groupName); //await Clients.Group(groupName).SendAsync("Send", $"{Context.ConnectionId} has joined the group {groupName}."); await Clients.Group(groupName).SendAsync("SendToGroup", $"{Context.ConnectionId}has joined the group {groupName}.", groupName, groupName); //calling Add to group API ChatGroupModel group = new ChatGroupModel(); group.Name = groupName; group.Owner = Context.GetHttpContext().Request.Query["UserName"]; var groupPayload = JsonConvert.SerializeObject(group); // Wrap our JSON inside a StringContent which then can be used by the HttpClient class var grouphttpContent = new StringContent(groupPayload, Encoding.UTF8, "application/json"); var createGroupUri = new Uri(string.Format(createGroupUrl, string.Empty)); HttpClient groupClient = new HttpClient(); var groupResponse = await groupClient.PostAsync(createGroupUri, grouphttpContent); }
public async Task <IActionResult> New(ChatGroupModel channel) { string imgPath = null; if (Request.Form.Files != null && Request.Form.Files.Count > 0) { imgPath = await(new S3Repository().UploadImage(Request.Form.Files[0])); } ChatGroup group = channel.ToChatGroup(); group.Picture = imgPath; var newChannelId = await groups.CreateGroup(group); if (!String.IsNullOrWhiteSpace(newChannelId)) { return(Redirect(newChannelId)); } return(View()); }