Refactor BL foorum service to use a factory for DTOS
This commit is contained in:
46
BL/Factories/FoorumFactory.cs
Normal file
46
BL/Factories/FoorumFactory.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BL.DTOs;
|
||||
using DAL.Domain;
|
||||
|
||||
namespace BL.Factories
|
||||
{
|
||||
public class FoorumFactory
|
||||
{
|
||||
public FoorumDTO Create(Foorum f, bool withPosts = false)
|
||||
{
|
||||
var dto = new FoorumDTO()
|
||||
{
|
||||
FoorumId = f.FoorumId,
|
||||
Title = f.Title,
|
||||
Author = f.Author,
|
||||
Body = f.Body,
|
||||
CreationTime = f.CreationTime,
|
||||
Description = f.Description,
|
||||
Visible = f.Visible
|
||||
};
|
||||
|
||||
if (withPosts)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//dto.Posts = new List<PostDTO>();
|
||||
//f.Posts.ForEach(p => {dto.Posts.Add();});
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Foorum Create(FoorumDTO f)
|
||||
{
|
||||
return new Foorum()
|
||||
{
|
||||
Author = f.Author,
|
||||
Body = f.Body,
|
||||
CreationTime = f.CreationTime,
|
||||
Description = f.Description,
|
||||
Title = f.Title
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user