Exemplo n.º 1
0
 public ActionResult LoadInitialData()
 {
     var model = new MessageListModel
     {
         Messages = _messageRepo.GetLatest(LatestVisibleMessages).Select(m => new ChatMessageDto(m))
     };
     return Json(model);
 }
Exemplo n.º 2
0
 public ActionResult CheckNewMessages(int? lastCheckedId)
 {
     var model = new MessageListModel
     {
         Messages = _messageRepo.GetLatestAfterId(lastCheckedId ?? 0).Select(m => new ChatMessageDto(m))
     };
     return Json(model);
 }
Exemplo n.º 3
0
 public ActionResult Send(NewMessageModel chatMessage)
 {
     if (ModelState.IsValid)
     {
         _messageRepo.Insert(new ChatMessage
             {
                 SendTime = DateTimeOffset.UtcNow,
                 Text = chatMessage.Message,
                 UserName = chatMessage.UserName
             });
         var model = new MessageListModel
         {
             Messages = _messageRepo.GetLatestAfterId(chatMessage.LastCheckedId ?? 0).Select(m => new ChatMessageDto(m))
         };
         return Json(model);
     }
     GenericErrorModel errorModel = new GenericErrorModel().SetModelErrors(ViewData);
     return Json(errorModel);
 }