From 44c733b5822e5898351b403c0318c96fdba09ca6 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Mon, 12 Jun 2017 15:26:34 +0300 Subject: [PATCH] Forum authro search is working --- BL/Services/FoorumService.cs | 5 ++++- WebApi/Controllers/FoorumController.cs | 1 + WebApi/Controllers/SearchController.cs | 26 ++++++++++++++++++++++++++ WebApi/WebApi.csproj | 1 + WebApi/index.html | 11 +++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 WebApi/Controllers/SearchController.cs diff --git a/BL/Services/FoorumService.cs b/BL/Services/FoorumService.cs index c327086..cb0e74f 100644 --- a/BL/Services/FoorumService.cs +++ b/BL/Services/FoorumService.cs @@ -56,7 +56,10 @@ namespace BL.Services public IEnumerable SearchFoorumAuthor(string query) { - throw new NotImplementedException(); + foreach (var f in _foorumRepository.GetMany(f => f.Author.ToLower().Contains(query.ToLower()))) + { + yield return _factory.Create(f); + } } public IEnumerable SearchFoorumTitle(string query) diff --git a/WebApi/Controllers/FoorumController.cs b/WebApi/Controllers/FoorumController.cs index e8141a7..2686db3 100644 --- a/WebApi/Controllers/FoorumController.cs +++ b/WebApi/Controllers/FoorumController.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; +using System.Web.Http.Controllers; using BL.DTOs; using BL.Interfaces; diff --git a/WebApi/Controllers/SearchController.cs b/WebApi/Controllers/SearchController.cs new file mode 100644 index 0000000..bbaa08b --- /dev/null +++ b/WebApi/Controllers/SearchController.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using BL.Interfaces; + +namespace WebApi.Controllers +{ + public class SearchController : ApiController + { + private readonly IFoorumService _foorumService; + + public SearchController(IFoorumService foorumService) + { + _foorumService = foorumService; + } + + + public IHttpActionResult Get(string author) + { + return Ok(_foorumService.SearchFoorumAuthor(author)); + } + } +} \ No newline at end of file diff --git a/WebApi/WebApi.csproj b/WebApi/WebApi.csproj index 4769e73..e0c12b1 100644 --- a/WebApi/WebApi.csproj +++ b/WebApi/WebApi.csproj @@ -112,6 +112,7 @@ + Global.asax diff --git a/WebApi/index.html b/WebApi/index.html index 63acecc..f54eafd 100644 --- a/WebApi/index.html +++ b/WebApi/index.html @@ -1,8 +1,10 @@

api

foorum +
+
\ No newline at end of file