public async System.Threading.Tasks.Task <IActionResult> Chat(ChatViewBindingModel model) { var user = await this.UserManager.GetUserAsync(User); this.groupService.CreateMessage(model.GroupId, user, model.Content); return(RedirectToAction("Chat", "Home", new { groupId = model.GroupId, area = "Users" })); }
public IActionResult Chat(int groupId) { var messages = this.groupService.GetGroupMessages(groupId); var messagesViews = new List <MessageViewModel>(); foreach (var message in messages) { bool messageIsFromUser = this.User.Identity.Name == message.Sender.UserName ? true : false; var messageView = new MessageViewModel(message.Sender.UserName, message.Content, messageIsFromUser); messagesViews.Add(messageView); } var chatView = new ChatViewBindingModel() { GroupId = groupId, MessageViews = messagesViews, }; return(View(chatView)); }