public IActionResult GetAll() { var response = Tracker.Conversations.ToDictionary( entry => entry.Key, entry => entry.Value .Select(pm => PrivateMessageResponse.FromPrivateMessage(pm, self: pm.Username == Client.Username)) .OrderBy(m => m.Timestamp)); return(Ok(response)); }
public IActionResult GetByUsername([FromRoute] string username) { if (Tracker.TryGet(username, out var conversation)) { var response = conversation .Select(pm => PrivateMessageResponse.FromPrivateMessage(pm, self: pm.Username == Client.Username)) .OrderBy(m => m.Timestamp); return(Ok(response)); } return(NotFound()); }
public async Task <SwaggerResponse <PrivateMessageResponse> > GetPrivateMessageListAsync(string username, string password) { var userAuthorization = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")); var response = await this.GetAsync($"{messageServiceUrl}/{username}", userAuthorization); if (!response.IsSuccessStatusCode) { var emptyPrivateMessageResponse = new PrivateMessageResponse { Messages = new ObservableCollection <PrivateMessage>(), Username = "" }; var emptyPrivateMessageSwaggerResponse = new SwaggerResponse <PrivateMessageResponse>(((int)response.StatusCode).ToString(), emptyPrivateMessageResponse) { Body = response.ReasonPhrase }; return(emptyPrivateMessageSwaggerResponse); } return(await this.CreateGenericSwaggerResponse <PrivateMessageResponse>(response)); }
public PrivateMessageResponse GetPrivateMessage(int pmid) { PrivateMessageResponse result = GetRequest <PrivateMessageResponse>(string.Concat(HFConstants.PrivateMessageUrl.Pm, pmid)); return(result); }