Getting a forum with id's works
This commit is contained in:
@@ -8,6 +8,7 @@ namespace BL.Factories
|
||||
{
|
||||
public class FoorumFactory
|
||||
{
|
||||
private readonly PostFactory _postFactory = new PostFactory();
|
||||
public FoorumDTO Create(Foorum f, bool withPosts = false)
|
||||
{
|
||||
var dto = new FoorumDTO()
|
||||
@@ -23,9 +24,8 @@ namespace BL.Factories
|
||||
|
||||
if (withPosts)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//dto.Posts = new List<PostDTO>();
|
||||
//f.Posts.ForEach(p => {dto.Posts.Add();});
|
||||
dto.Posts = new List<PostDTO>();
|
||||
f.Posts.ForEach(p => {dto.Posts.Add(_postFactory.Create(p));});
|
||||
}
|
||||
|
||||
return dto;
|
||||
|
||||
33
BL/Factories/PostFactory.cs
Normal file
33
BL/Factories/PostFactory.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BL.DTOs;
|
||||
using DAL.Domain;
|
||||
|
||||
namespace BL.Factories
|
||||
{
|
||||
public class PostFactory
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user