2017-06-12 13:37:48 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using BL.DTOs;
|
2017-06-12 14:28:07 +03:00
|
|
|
|
using BL.Factories;
|
2017-06-12 13:37:48 +03:00
|
|
|
|
using BL.Interfaces;
|
|
|
|
|
using DAL.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace BL.Services
|
|
|
|
|
{
|
|
|
|
|
public class FoorumService : IFoorumService
|
|
|
|
|
{
|
2017-06-12 14:28:07 +03:00
|
|
|
|
private readonly IFoorumRepository _foorumRepository;
|
|
|
|
|
private readonly FoorumFactory _factory;
|
2017-06-12 13:37:48 +03:00
|
|
|
|
public FoorumService(IFoorumRepository foorumRepository)
|
|
|
|
|
{
|
|
|
|
|
_foorumRepository = foorumRepository;
|
2017-06-12 14:28:07 +03:00
|
|
|
|
_factory = new FoorumFactory();
|
2017-06-12 13:37:48 +03:00
|
|
|
|
}
|
2017-06-12 14:16:38 +03:00
|
|
|
|
public FoorumDTO Add(FoorumDTO foorum)
|
2017-06-12 13:37:48 +03:00
|
|
|
|
{
|
2017-06-12 14:28:07 +03:00
|
|
|
|
var foorumDomain = _factory.Create(foorum);
|
|
|
|
|
foorumDomain.CreationTime = DateTime.Now;
|
2017-06-12 14:16:38 +03:00
|
|
|
|
var f = _foorumRepository.Add(foorumDomain);
|
2017-06-12 14:28:07 +03:00
|
|
|
|
return _factory.Create(f);
|
2017-06-12 13:37:48 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddPost(int id, PostDTO post)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Delete(int id)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FoorumDTO Get(int id)
|
|
|
|
|
{
|
2017-06-12 14:43:31 +03:00
|
|
|
|
var f =_foorumRepository.GetById(id);
|
|
|
|
|
return _factory.Create(f, withPosts:true);
|
2017-06-12 13:37:48 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<FoorumDTO> GetAll()
|
|
|
|
|
{
|
|
|
|
|
foreach (var f in _foorumRepository.GetAll())
|
|
|
|
|
{
|
2017-06-12 14:28:07 +03:00
|
|
|
|
yield return _factory.Create(f);
|
2017-06-12 13:37:48 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Hide(int id)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<FoorumDTO> SearchFoorumAuthor(string query)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<FoorumDTO> SearchFoorumTitle(string query)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<PostDTO> SearchPostAuthor(string query)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(FoorumDTO foorum)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|