public async Task <IActionResult> GetUrls([FromBody] StartParametrs startParametrs) { try { if (string.IsNullOrWhiteSpace(startParametrs.Message) || startParametrs.Count == 0) { return(BadRequest()); } var userName = HttpContext.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; if (string.IsNullOrWhiteSpace(userName)) { return(Unauthorized()); } var user = await _userManager.FindByNameAsync(userName); var messages = await this._googleSearchService.CustomSearchAsync(startParametrs.Message, startParametrs.Count); return(Ok(new { ok = "ok", messages = messages })); } catch (Exception ex) { await this._telegramService.SendMessageExceptionAsync(ex); return(StatusCode(500, ex)); } }
public async Task <IActionResult> Start([FromBody] StartParametrs startParametrs) { try { if (string.IsNullOrWhiteSpace(startParametrs.Message) || startParametrs.Count == 0) { return(BadRequest()); } var userName = HttpContext.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; if (string.IsNullOrWhiteSpace(userName)) { return(Unauthorized()); } var user = await _userManager.FindByNameAsync(userName); var id = await this.Run(user.Id, startParametrs.Count, startParametrs.Message.Split(new[] { ' ', '\n' }).Select(uri => new Uri(uri))); return(Ok(new { ok = "ok", id = id })); } catch (Exception ex) { await this._telegramService.SendMessageExceptionAsync(ex); return(StatusCode(500, ex)); } }