public async Task <IActionResult> SendMessage() { var userId = this.User.GetUserId(); var viewModel = new ChatSendMessageInputModel(); viewModel.Users = await this.usersService.GetChatUsersAsync <ChatUserViewModel>(userId); return(this.View(viewModel)); }
public async Task <IActionResult> SendMessage() { var viewModel = new ChatSendMessageInputModel { Users = await this.usersService.GetAllAsync <ChatUserViewModel>(), }; return(this.View(viewModel)); }
public async Task <IActionResult> SendMessage(ChatSendMessageInputModel input) { if (!this.ModelState.IsValid) { input.Users = await this.usersService.GetAllAsync <ChatUserViewModel>(); this.View(input); } await this.messagesService.CreateAsync(input.Message, this.User.GetId(), input.ReceiverId); return(this.RedirectToAction(nameof(WithUser), new { id = input.ReceiverId })); }
public async Task <IActionResult> SendMessage(ChatSendMessageInputModel input) { var userId = this.User.GetUserId(); if (!this.ModelState.IsValid) { input.Users = await this.usersService.GetChatUsersAsync <ChatUserViewModel>(userId); return(this.View(input)); } await this.messagesService.CreateMessageAsync(userId, input.UserId, input.Content); return(this.RedirectToAction(nameof(this.ChatWithUser), new { Id = input.UserId })); }