public async ValueTask <ApiResultContract <MessageRestApiModel> > ByIdAsync([FromQuery] string topicId, [FromQuery] long messageId) { var(message, _) = await ServiceLocator.MessagesContentReader.TryGetMessageAsync(topicId, messageId, "API"); if (message == null) { return(ApiResultContract <MessageRestApiModel> .CreateFail(ApiResult.RecordNotFound)); } return(ApiResultContract <MessageRestApiModel> .CreateOk(MessageRestApiModel.Create(message))); }
public async ValueTask <IActionResult> ListFromMessageIdAsync( [FromQuery] string topicId, [FromQuery] long messageId, [FromQuery] int maxAmount) { if (maxAmount > Startup.Settings.MaxResponseRecordsAmount) { return(StatusCode(403, "Maximum amount of records can be less then " + Startup.Settings.MaxResponseRecordsAmount)); } var messages = await ServiceLocator.MessagesContentReader.GetMessagesFromMessageId(topicId, messageId, maxAmount, "API Request").ToListAsync(); return(Json(ApiResultContract <IEnumerable <MessageRestApiModel> > .CreateOk(messages.Select(MessageRestApiModel.Create)))); }