From 278130d86378a6b2db6ba443631f303fb7d7e207 Mon Sep 17 00:00:00 2001 From: transtrike Date: Wed, 30 Dec 2020 21:21:49 +0200 Subject: Implemented Posts and merged Comment to Post --- src/DevHive.Services/Services/CommentService.cs | 62 ------------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/DevHive.Services/Services/CommentService.cs (limited to 'src/DevHive.Services/Services/CommentService.cs') 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 CreateComment(CommentServiceModel commentServiceModel) - { - Comment comment = this._commentMapper.Map(commentServiceModel); - comment.Date = DateTime.Now; - bool result = await this._commentRepository.AddAsync(comment); - - return result; - } - - public async Task 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(comment); - } - - public async Task UpdateComment(UpdateCommentServiceModel commentServiceModel) - { - if (!await this._commentRepository.DoesCommentExist(commentServiceModel.Id)) - throw new ArgumentException("Comment does not exist!"); - - Comment comment = this._commentMapper.Map(commentServiceModel); - bool result = await this._commentRepository.EditAsync(comment); - - return result; - } - - public async Task 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 -- cgit v1.2.3