Poszukiwacz/Serwer/Serwer.Api/Controllers/SearchController.cs
2021-01-09 14:44:14 +01:00

32 lines
863 B
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Serwer.Infrastructure.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Serwer.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class SearchController : ControllerBase
{
private readonly ISearchService _searchService;
public SearchController(ISearchService searchService)
{
_searchService = searchService;
}
[Authorize]
[HttpGet("{query}")]
public async Task<IActionResult> Search(string query)
{
var id = User.Identity.Name;
var results = await _searchService.Search(Guid.Parse(id), query);
return Ok(results);
}
}
}