public async Task <IActionResult> Get([FromRoute] string id, [FromQuery(Name = "search")] string search = null, [FromQuery(Name = "user")] string user = null, [FromQuery(Name = "startDate")] DateTime?startDate = null, [FromQuery(Name = "endDate")] DateTime?endDate = null, [FromQuery(Name = "pageIndex")] int?pageIndex = null, [FromQuery(Name = "pageSize")] int?pageSize = null) { var linkReaderId = Guid.Parse(id); var linkReader = await _linkReaderBO.GetAsync(linkReaderId); var isAPIRequest = Request.Headers.ContainsKey("IsAPIRequest") ? bool.Parse(Request.Headers["IsAPIRequest"]) : true; object result = null; if (HttpContext.Request.ContentType != null && HttpContext.Request.ContentType.ToLowerInvariant().StartsWith("application/json")) { result = await _linkBO.GetAsync(linkReader, isAPIRequest, search, user, startDate, endDate, pageIndex, pageSize); return(Ok(result)); } else { return(RedirectToPage($"/Index/{linkReaderId}")); } }
public async Task <IActionResult> OnGetAsync(Guid id) { try { var linkReader = await _linkReaderBO.GetAsync(id); ChatId = id; Chats = await _linkReaderBO.GetRelatedLinkReadersAsync(linkReader.LinkReaderId); DefaultStartDate = DateTime.Now.AddMonths(-1); DefaultEndDate = DateTime.Now; return(Page()); } catch (Exception) { return(RedirectToPage("Error")); } }
public async Task SendLinksRecoverMessageAsync(long chatId, int userId, string chatTitle, int replyToMessageId) { try { var rootUri = Configuration.GetSection("AppConfiguration")["RootUri"]; var linkReader = await _linkReaderBO.GetAsync(userId, chatId); if (linkReader == null) { linkReader = await _linkReaderBO.SaveAsync(userId, chatId); } var message = string.Format(MessageResources.LinksRecover, string.IsNullOrEmpty(chatTitle) ? "" : $" {chatTitle}", $"{rootUri}/{linkReader.LinkReaderId.ToString()}" ); await BotClient.SendTextMessageAsync(userId, message, ParseMode.Default, true, true); } catch (ChatNotInitiatedException exception) { Logger.LogError(exception.Message); var replyMarkup = new InlineKeyboardMarkup(new InlineKeyboardButton { Text = MessageResources.StartChat, Url = Configuration.GetSection("AppConfiguration")["StartChatUri"] }); await BotClient.SendTextMessageAsync(chatId, ExceptionResources.ChatNotInitiatedException, ParseMode.Markdown, true, false, replyToMessageId, replyMarkup); } catch (ApiRequestException exception) { Logger.LogError(exception.Message); await BotClient.SendTextMessageAsync(chatId, ExceptionResources.ApiRequestException, ParseMode.Default, true, true, replyToMessageId); } catch (Exception exception) { Logger.LogError(exception.Message); await BotClient.SendTextMessageAsync(chatId, ExceptionResources.UnknownException, ParseMode.Default, true, true, replyToMessageId); } }