aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services/Services/CommentService.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-30 21:21:49 +0200
committertranstrike <transtrike@gmail.com>2020-12-30 21:21:49 +0200
commit278130d86378a6b2db6ba443631f303fb7d7e207 (patch)
tree72fa0ad4889a9f18cdd0a54992dc151784323c83 /src/DevHive.Services/Services/CommentService.cs
parenta96478dd52250c4f5b494c66806d5e97156c48b3 (diff)
downloadDevHive-278130d86378a6b2db6ba443631f303fb7d7e207.tar
DevHive-278130d86378a6b2db6ba443631f303fb7d7e207.tar.gz
DevHive-278130d86378a6b2db6ba443631f303fb7d7e207.zip
Implemented Posts and merged Comment to Post
Diffstat (limited to 'src/DevHive.Services/Services/CommentService.cs')
-rw-r--r--src/DevHive.Services/Services/CommentService.cs62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/DevHive.Services/Services/CommentService.cs b/src/DevHive.Services/Services/CommentService.cs
deleted file mode 100644
index 69dbcc0..0000000
--- a/src/DevHive.Services/Services/CommentService.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Data.Models;
-using DevHive.Data.Repositories;
-using DevHive.Services.Models.Comment;
-
-namespace DevHive.Services.Services
-{
- public class CommentService
- {
- private readonly CommentRepository _commentRepository;
- private readonly IMapper _commentMapper;
-
- public CommentService(CommentRepository commentRepository, IMapper mapper)
- {
- this._commentRepository = commentRepository;
- this._commentMapper = mapper;
- }
-
- public async Task<bool> CreateComment(CommentServiceModel commentServiceModel)
- {
- Comment comment = this._commentMapper.Map<Comment>(commentServiceModel);
- comment.Date = DateTime.Now;
- bool result = await this._commentRepository.AddAsync(comment);
-
- return result;
- }
-
- public async Task<GetByIdCommentServiceModel> GetCommentById(Guid id)
- {
- Comment comment = await this._commentRepository.GetByIdAsync(id);
-
- if(comment == null)
- throw new ArgumentException("The comment does not exist");
-
- return this._commentMapper.Map<GetByIdCommentServiceModel>(comment);
- }
-
- public async Task<bool> UpdateComment(UpdateCommentServiceModel commentServiceModel)
- {
- if (!await this._commentRepository.DoesCommentExist(commentServiceModel.Id))
- throw new ArgumentException("Comment does not exist!");
-
- Comment comment = this._commentMapper.Map<Comment>(commentServiceModel);
- bool result = await this._commentRepository.EditAsync(comment);
-
- return result;
- }
-
- public async Task<bool> DeleteComment(Guid id)
- {
- if (!await this._commentRepository.DoesCommentExist(id))
- throw new ArgumentException("Comment does not exist!");
-
- Comment comment = await this._commentRepository.GetByIdAsync(id);
- bool result = await this._commentRepository.DeleteAsync(comment);
-
- return result;
- }
- }
-} \ No newline at end of file