public IList <ChatMessage> GetMessagesInChat(int chatId) { var chatMessages = chatMessageService.GetChatMessages() ?? new List <ChatMessage>(); var messagesInChat = chatMessages .Where(m => m.ChatId == chatId) .ToList(); return(messagesInChat); }
public IActionResult GetMessages([FromBody] MsgPost body) { var userId = HttpContext.GetUserID(); if (!_roomService.HasUserAccess(body.roomId, userId)) { return(Unauthorized()); } var chatMessages = _chatMessageService.GetChatMessages(body.roomId, body.count).ToList(); return(Json(chatMessages)); }
public async Task GetRoomMessages(Guid roomId) { try { var messages = _chatMessageService.GetChatMessages(roomId); var result = _mapper.Map <ICollection <ChatMessageModel> >(messages); await this.Clients.Caller.RoomMessagesList(result); } catch (Exception ex) { throw; } }
public ActionResult GetChatMessage(GetChatMessageModel model) { _ilog.Info(string.Format("方法名:{0};参数:{1}", "GetChatMessage", Serializer.ToJson(model))); var result = new StandardJsonResult <dynamic>(); result.Try(() => { if (!ModelState.IsValid) { throw new KnownException(ModelState.GetFirstError()); } int count = 0; var list = service.GetChatMessages(BCSession.User.UserID, BCSession.User.Device, model.PageSize, model.QueryTime, out count); result.Value = new { Data = list }; }); _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "GetChatMessage", Serializer.ToJson(result))); return(result); }
public HttpResponseMessage GetAllChatMessages() { return(base.BuildSuccessResult(HttpStatusCode.OK, _chatMessagesService.GetChatMessages())); }