public IActionResult GetMessageHistory(string personId) { var userId = _userManager.GetUserId(HttpContext.User); var history = _messagesRepository.GetMessageHistory(userId, personId, MESSAGES_AMOUNT.ALL); return(new OkObjectResult(history)); }
public async Task OnGetHistory(string personId) { var owner = await _userManager.GetUserAsync(Context.User); var ownerId = owner.Id; var history = _messagesRepository .GetMessageHistory(ownerId, personId, MESSAGES_AMOUNT.ALL) .OrderBy(m => m.ServerDateUtc) .ToList(); var json = JsonConvert.SerializeObject(history, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); await Clients.Client(Context.ConnectionId).InvokeAsync("OnGetHistory", json); }