Changeset 7fbb91c for ChapterX.API/Controllers/CollaborationsController.cs
- Timestamp:
- 03/24/26 23:03:39 (3 months ago)
- Branches:
- main
- Children:
- a7550ca
- Parents:
- 73b69b2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ChapterX.API/Controllers/CollaborationsController.cs
r73b69b2 r7fbb91c 1 1 using ChapterX.Application.Collaboration.Commands; 2 2 using ChapterX.Application.Collaboration.Queries; 3 using ChapterX.Domain.Repositories; 3 4 using MediatR; 4 5 using Microsoft.AspNetCore.Authorization; … … 13 14 { 14 15 private readonly IMediator _mediator; 16 private readonly ICollaborationRepository _collaborationRepository; 15 17 private readonly ILogger<CollaborationsController> _logger; 16 18 17 public CollaborationsController(IMediator mediator, I Logger<CollaborationsController> logger)19 public CollaborationsController(IMediator mediator, ICollaborationRepository collaborationRepository, ILogger<CollaborationsController> logger) 18 20 { 19 21 _mediator = mediator; 22 _collaborationRepository = collaborationRepository; 20 23 _logger = logger; 21 24 } … … 26 29 { 27 30 _logger.LogInformation("Fetching all collaborations"); 28 var response = await _mediator.Send(new GetAllRequest()); 29 return Ok(response); 31 var collabs = await _collaborationRepository.GetAllAsync(); 32 var result = collabs.Select(c => new 33 { 34 id = c.Id, 35 userId = c.UserId, 36 storyId = c.StoryId, 37 username = c.User != null ? c.User.Username : "", 38 name = c.User != null ? c.User.Name : "", 39 createdAt = c.CreatedAt, 40 }); 41 return Ok(result); 42 } 43 44 [HttpDelete("user/{userId:int}/story/{storyId:int}")] 45 [Authorize] 46 public async Task<ActionResult> DeleteByUserAndStory(int userId, int storyId) 47 { 48 var deleted = await _collaborationRepository.DeleteByUserAndStoryAsync(userId, storyId); 49 if (!deleted) return NotFound(); 50 return Ok(); 30 51 } 31 52
Note:
See TracChangeset
for help on using the changeset viewer.
