Working forum post

This commit is contained in:
2017-06-12 14:16:38 +03:00
parent aeb18aa75b
commit 4aadaf08fe
8 changed files with 75 additions and 22 deletions

View File

@@ -40,7 +40,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="DTOs\FoorumDTO.cs" />
<Compile Include="DTOs\PostDTO.cs" />
<Compile Include="Interfaces\IFoorumService.cs" />

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BL
{
public class Class1
{
}
}

View File

@@ -10,6 +10,13 @@ namespace BL.DTOs
{
public int FoorumId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Body { get; set; }
public DateTime CreationTime { get; set; }
public string Author { get; set; }
public bool Visible { get; set; }
public List<PostDTO> Posts { get; set; }
}
}

View File

@@ -11,7 +11,7 @@ namespace BL.Interfaces
{
IEnumerable<FoorumDTO> GetAll();
FoorumDTO Get(int id);
void Add(FoorumDTO foorum);
FoorumDTO Add(FoorumDTO foorum);
void Update(FoorumDTO foorum);
void Hide(int id);
void Delete(int id);

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using BL.DTOs;
using BL.Interfaces;
using DAL.Domain;
using DAL.Interfaces;
namespace BL.Services
@@ -16,9 +18,27 @@ namespace BL.Services
{
_foorumRepository = foorumRepository;
}
public void Add(FoorumDTO foorum)
public FoorumDTO Add(FoorumDTO foorum)
{
throw new NotImplementedException();
var foorumDomain = new Foorum()
{
Author = foorum.Author,
Body = foorum.Body,
CreationTime = DateTime.Now,
Description = foorum.Description,
Title = foorum.Title
};
var f = _foorumRepository.Add(foorumDomain);
return new FoorumDTO()
{
FoorumId = f.FoorumId,
Title = f.Title,
Author = f.Author,
Body = f.Body,
CreationTime = f.CreationTime,
Description = f.Description,
Visible = f.Visible
};
}
public void AddPost(int id, PostDTO post)
@@ -43,7 +63,12 @@ namespace BL.Services
yield return new FoorumDTO()
{
FoorumId = f.FoorumId,
Title = f.Title
Title = f.Title,
Author = f.Author,
Body = f.Body,
CreationTime = f.CreationTime,
Description = f.Description,
Visible = f.Visible
};
}