public AdminController(ApplicationContext context, EventLoggerService eventLogger) { _eventLogger = eventLogger; _eventLogger.AddClass <AdminController>(); _eventLogger.LogDebug("Initialization AdminController"); _context = context; }
public MessageController(ApplicationContext context, EventLoggerService eventLogger, TelegramBotService telegramBot, TelegramMarkupsService markups) { _eventLogger = eventLogger; _context = context; _telegramBot = telegramBot; _markups = markups; _eventLogger.AddClass <MessageController>(); _eventLogger.LogDebug("Initialization MessageController"); }
public async Task <IActionResult> Post([FromBody] Update update) { if (update == null) { return(Ok()); } var message = update.Message; try { var commands = _telegramBot.Commands; var textCommands = _telegramBot.TextCommands; var telegramBot = _telegramBot.GetBotClient(); _eventLogger.LogDebug($"Received {message.Type}", message.From.Id.ToString()); foreach (var command in commands) { if (!command.Contains(message)) { continue; } await command.Execute(message, telegramBot, _context, _markups); return(Ok()); } foreach (var textCommand in textCommands) { var contains = !(await textCommand.Contains(message, _context)); if (contains) { continue; } await textCommand.Execute(message, telegramBot, _context, _markups); return(Ok()); } } catch (Exception e) { _eventLogger.LogError(e, message.From.Id.ToString()); } return(Ok()); }
public IActionResult Index() { _eventLogger.LogDebug("/Home/Index page visited"); return(View()); }
public async Task <IActionResult> Translate() { _eventLogger.LogDebug("/Admin/TranslateView page visited"); return(View(await _context.Lines.ToListAsync())); }