53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using BL.DTOs;
|
|
using BL.Interfaces;
|
|
using DAL.Domain;
|
|
|
|
namespace BL.Factories
|
|
{
|
|
public class PostFactory
|
|
{
|
|
private readonly IFoorumService _foorumService;
|
|
public PostFactory(IFoorumService foorumService)
|
|
{
|
|
_foorumService = foorumService;
|
|
}
|
|
|
|
public PostDTO Create(Post p, bool withForum=false)
|
|
{
|
|
var dto = new PostDTO()
|
|
{
|
|
PostId = p.PostId,
|
|
Title = p.Title,
|
|
Author = p.Author,
|
|
Body = p.Body,
|
|
CreationTime = p.CreationTime,
|
|
};
|
|
|
|
if (withForum)
|
|
{
|
|
dto.Foorum = _foorumService.Get(p.ForumId, withPosts:false);
|
|
}
|
|
|
|
return dto;
|
|
}
|
|
|
|
public Post Create(PostDTO p)
|
|
{
|
|
var domain = new Post()
|
|
{
|
|
PostId = p.PostId,
|
|
Title = p.Title,
|
|
Author = p.Author,
|
|
Body = p.Body,
|
|
CreationTime = p.CreationTime,
|
|
};
|
|
return domain;
|
|
}
|
|
}
|
|
}
|