using System; using System.Collections.Generic; using BL.DTOs; using BL.Factories; using BL.Interfaces; using DAL.Interfaces; namespace BL.Services { public class FoorumService : IFoorumService { private readonly IFoorumRepository _foorumRepository; private readonly FoorumFactory _factory; public FoorumService(IFoorumRepository foorumRepository) { _foorumRepository = foorumRepository; _factory = new FoorumFactory(); } public FoorumDTO Add(FoorumDTO foorum) { var foorumDomain = _factory.Create(foorum); foorumDomain.CreationTime = DateTime.Now; var f = _foorumRepository.Add(foorumDomain); return _factory.Create(f); } public void AddPost(int id, PostDTO post) { throw new NotImplementedException(); } public void Delete(int id) { throw new NotImplementedException(); } public FoorumDTO Get(int id) { var f =_foorumRepository.GetById(id); return _factory.Create(f, withPosts:true); } public IEnumerable GetAll() { foreach (var f in _foorumRepository.GetAll()) { yield return _factory.Create(f); } } public void Hide(int id) { throw new NotImplementedException(); } public IEnumerable SearchFoorumAuthor(string query) { foreach (var f in _foorumRepository.GetMany(f => f.Author.ToLower().Contains(query.ToLower()))) { yield return _factory.Create(f); } } public IEnumerable SearchFoorumTitle(string query) { throw new NotImplementedException(); } public IEnumerable SearchPostAuthor(string query) { throw new NotImplementedException(); } public void Update(FoorumDTO foorum) { throw new NotImplementedException(); } } }