diff --git a/aait/backend/group-1A/Application/Contracts/IAuthRepository.cs b/aait/backend/group-1A/Application/Contracts/IAuthRepository.cs index 553f833a2..f9b6c2ff6 100644 --- a/aait/backend/group-1A/Application/Contracts/IAuthRepository.cs +++ b/aait/backend/group-1A/Application/Contracts/IAuthRepository.cs @@ -10,5 +10,4 @@ public interface IAuthRepository{ Task UserExists(string username); - } \ No newline at end of file diff --git a/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/CreateCommentHandler.cs b/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/CreateCommentHandler.cs index 1d977339c..7902ffe06 100644 --- a/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/CreateCommentHandler.cs +++ b/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/CreateCommentHandler.cs @@ -54,7 +54,7 @@ public async Task> Handle(CommentCreateCommand await _mediator.Send(new CreateNotification { NotificationData = new NotificationCreateDTO() { - Content = "A Comment has been given on your post", + Content = $"User with Id {request.userId} commented on your post with Id {request.NewCommentData.PostId}", NotificationContentId = result.Id, NotificationType = NotificationEnum.COMMENT, UserId = post.UserId diff --git a/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/DeleteCommentHandler.cs b/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/DeleteCommentHandler.cs index 053423816..ba21fb942 100644 --- a/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/DeleteCommentHandler.cs +++ b/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/DeleteCommentHandler.cs @@ -38,7 +38,7 @@ public async Task> Handle(CommentDeleteCommand request, Cancel await _mediator.Send(new CreateNotification {NotificationData = new NotificationCreateDTO() { - Content = "A comment on your post has been removed", + Content = $"A comment on your post made by user with Id {request.userId} has been removed", NotificationContentId = comment.Id, NotificationType = NotificationEnum.COMMENT, UserId = post.UserId diff --git a/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/UpdateCommentHandler.cs b/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/UpdateCommentHandler.cs index 8701878cb..1b57dbb4d 100644 --- a/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/UpdateCommentHandler.cs +++ b/aait/backend/group-1A/Application/Features/CommentFeatures/Handlers/Commands/UpdateCommentHandler.cs @@ -52,7 +52,7 @@ public async Task> Handle(UpdateCommentCommand await _mediator.Send(new CreateNotification {NotificationData = new NotificationCreateDTO() { - Content = "A comment on your post has been Updated", + Content = $"A comment on your post made by user with id {request.userId} has been Updated", NotificationContentId = comment.Id, NotificationType = NotificationEnum.COMMENT, UserId = post.UserId} diff --git a/aait/backend/group-1A/Application/Features/CommentReactionFeature/Handlers/Commands/MakeCommentReactionHandler.cs b/aait/backend/group-1A/Application/Features/CommentReactionFeature/Handlers/Commands/MakeCommentReactionHandler.cs index 245048484..c25805600 100644 --- a/aait/backend/group-1A/Application/Features/CommentReactionFeature/Handlers/Commands/MakeCommentReactionHandler.cs +++ b/aait/backend/group-1A/Application/Features/CommentReactionFeature/Handlers/Commands/MakeCommentReactionHandler.cs @@ -64,14 +64,6 @@ public async Task> Handle(MakeReactionOnComment request, Cance throw new BadRequestException("Comment is not found"); } - await _mediator.Send(new CreateNotification { - NotificationData = new NotificationCreateDTO() - { - Content = $"User with {request.UserId} reacted on your comment", - NotificationType = NotificationEnum.COMMENTREACTION, - UserId = request.UserId} - } - ); return new BaseResponse() { diff --git a/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/CreateFollowCommandHandler.cs b/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/CreateFollowCommandHandler.cs index 6d0c90ae2..cd5c76087 100644 --- a/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/CreateFollowCommandHandler.cs +++ b/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/CreateFollowCommandHandler.cs @@ -49,7 +49,7 @@ public async Task> Handle(CreateFollowCommand request, Cancell await _mediator.Send(new CreateNotification {NotificationData = new NotificationCreateDTO() { - Content = $"The user with {request.FollowDTO.FollowerId} is currently following you", + Content = $"The user with Id {request.FollowDTO.FollowerId} is currently following you", NotificationType = NotificationEnum.FOLLOW, UserId = request.FollowDTO.FolloweeId}}); diff --git a/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/DeleteFollowCommandHandler.cs b/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/DeleteFollowCommandHandler.cs index 040427c30..4308f00fb 100644 --- a/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/DeleteFollowCommandHandler.cs +++ b/aait/backend/group-1A/Application/Features/FollowFeature/Handlers/Commands/DeleteFollowCommandHandler.cs @@ -47,14 +47,14 @@ public async Task> Handle(DeleteFollowCommand request, Cancell await _mediator.Send(new CreateNotification {NotificationData = new NotificationCreateDTO() { - Content = $"The user with {request.FollowDTO.FollowerId} has currently un followed you", + Content = $"The user with Id {request.FollowDTO.FollowerId} has currently un followed you", NotificationType = NotificationEnum.FOLLOW, UserId = request.FollowDTO.FolloweeId }}); createFollowResponse.Success = true; - createFollowResponse.Message = $"User with Id {followEntity.FollowerId} has un followed you"; + createFollowResponse.Message = $"You have unfollowed the user with Id {request.FollowDTO.FolloweeId}"; createFollowResponse.Value = followEntity.FolloweeId; return createFollowResponse; } diff --git a/aait/backend/group-1A/Application/Features/PostFeature/Handlers/Commands/CreatePostHandler.cs b/aait/backend/group-1A/Application/Features/PostFeature/Handlers/Commands/CreatePostHandler.cs index 2263f8ae4..c279d7fc4 100644 --- a/aait/backend/group-1A/Application/Features/PostFeature/Handlers/Commands/CreatePostHandler.cs +++ b/aait/backend/group-1A/Application/Features/PostFeature/Handlers/Commands/CreatePostHandler.cs @@ -54,7 +54,7 @@ public async Task> Handle(CreatePostCommand reques if (tagEntity == null) { - var newTag = new Tag + var newTag = new Tag() { Title = tag }; @@ -78,7 +78,7 @@ await _mediator.Send( new CreateNotification () { NotificationData = new NotificationCreateDTO() { - Content = "A Post has been Created", + Content = $"User with Id {request.userId} has created a post", NotificationContentId = result.Id, NotificationType = NotificationEnum.POST, UserId = request.userId diff --git a/aait/backend/group-1A/Persistence/Repositories/TagRepositories/TagRepositories.cs b/aait/backend/group-1A/Persistence/Repositories/TagRepositories/TagRepositories.cs index 23e214920..bdf5064d0 100644 --- a/aait/backend/group-1A/Persistence/Repositories/TagRepositories/TagRepositories.cs +++ b/aait/backend/group-1A/Persistence/Repositories/TagRepositories/TagRepositories.cs @@ -18,7 +18,9 @@ public TagReposiotry(SocialMediaDbContext socialMediaDbContext) } public Task Add(Tag entity) { - throw new NotImplementedException(); + _socialMediaDbContext.Tags.Add(entity); + _socialMediaDbContext.SaveChanges(); + return Task.FromResult(entity); } diff --git a/aait/backend/group-1A/WebApi/Controllers/CommentReactionController.cs b/aait/backend/group-1A/WebApi/Controllers/CommentReactionController.cs index 99fda4682..1d4f97be6 100644 --- a/aait/backend/group-1A/WebApi/Controllers/CommentReactionController.cs +++ b/aait/backend/group-1A/WebApi/Controllers/CommentReactionController.cs @@ -41,7 +41,7 @@ public async Task>>> GetDisl public async Task>> Post([FromBody] ReactionDTO reactionData) { var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier)!.Value); - var result = await _mediator.Send(new MakeReactionOnComment{ UserId = 3, ReactionData = reactionData }); + var result = await _mediator.Send(new MakeReactionOnComment{ UserId = userId, ReactionData = reactionData }); return Ok(result); } diff --git a/aait/backend/group-1A/WebApi/Controllers/PostController.cs b/aait/backend/group-1A/WebApi/Controllers/PostController.cs index e5b3999f7..829e764c9 100644 --- a/aait/backend/group-1A/WebApi/Controllers/PostController.cs +++ b/aait/backend/group-1A/WebApi/Controllers/PostController.cs @@ -85,8 +85,8 @@ public async Task>> Delete(int id) } [HttpGet("/tag/{tagname}")] - public async Task>> GetByTagName(GetPostsByTagQuery query){ - var result = await _mediator.Send(query); + public async Task>> GetByTagName(string tagname){ + var result = await _mediator.Send(new GetPostsByTagQuery { TagName = tagname }); return Ok(result); } diff --git a/aait/backend/group-1A/WebApi/Controllers/TagController.cs b/aait/backend/group-1A/WebApi/Controllers/TagController.cs deleted file mode 100644 index cf54c11c2..000000000 --- a/aait/backend/group-1A/WebApi/Controllers/TagController.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Application.Response; -using MediatR; -using Microsoft.AspNetCore.Mvc; -using SocialSync.Application.DTO; -using SocialSync.Application.Features.Requests; - -namespace SocialSync.WebApi.Controllers; - -[ApiController] -[Route("[controller]")] -public class TagController : ControllerBase{ - - private readonly IMediator _mediator; - public TagController(IMediator mediator) - { - _mediator = mediator; - - } - - [HttpPost] - public async Task>> Post(CreateTagCommand command){ - - var result = await _mediator.Send(command); - return Ok(result); - } - - [HttpGet] - public async Task>>> Get(){ - var result = await _mediator.Send(new GetAllTagsRequest()); - return Ok(result); - } - - [HttpGet("{id}")] - public IActionResult Get(int id){ - return Ok(); - } - - [HttpPut("{id}")] - public IActionResult Update(UpdateTagRequest request){ - var result = _mediator.Send(request); - if (result.IsCompletedSuccessfully) - { - return NoContent(); - } - else - { - return BadRequest(); - } - - } - - [HttpDelete("{id}")] - public IActionResult Delete(DeleteTagRequest request){ - - var result = _mediator.Send(request); - - if(result.IsCompletedSuccessfully){ - return NoContent(); - } - return BadRequest(); - } - -} \ No newline at end of file