Changeset b373fea for ChapterX.Application
- Timestamp:
- 06/23/26 15:20:39 (13 days ago)
- Branches:
- main
- Children:
- 0b502c2
- Parents:
- d300631
- Location:
- ChapterX.Application
- Files:
-
- 17 edited
-
Auth/LoginRequest.cs (modified) (1 diff)
-
Auth/RegisterRequest.cs (modified) (1 diff)
-
Chapter/Commands/AddRequest.cs (modified) (1 diff)
-
Chapter/Commands/DeleteHandler.cs (modified) (1 diff)
-
Chapter/Commands/DeleteRequest.cs (modified) (1 diff)
-
Chapter/Commands/UpdateHandler.cs (modified) (1 diff)
-
Chapter/Commands/UpdateRequest.cs (modified) (1 diff)
-
Comment/Commands/AddRequest.cs (modified) (1 diff)
-
Comment/Commands/DeleteHandler.cs (modified) (1 diff)
-
Comment/Commands/DeleteRequest.cs (modified) (1 diff)
-
Comment/Commands/UpdateHandler.cs (modified) (1 diff)
-
Comment/Commands/UpdateRequest.cs (modified) (1 diff)
-
Story/Commands/AddRequest.cs (modified) (1 diff)
-
Story/Commands/DeleteHandler.cs (modified) (1 diff)
-
Story/Commands/DeleteRequest.cs (modified) (1 diff)
-
Story/Commands/UpdateHandler.cs (modified) (1 diff)
-
Story/Commands/UpdateRequest.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ChapterX.Application/Auth/LoginRequest.cs
rd300631 rb373fea 1 1 using MediatR; 2 using System.ComponentModel.DataAnnotations; 2 3 3 4 namespace ChapterX.Application.Auth 4 5 { 5 public record LoginRequest(string Email, string Password) : IRequest<LoginResponse>; 6 public record LoginRequest( 7 [Required][EmailAddress][MaxLength(200)] string Email, 8 [Required][MaxLength(128)] string Password 9 ) : IRequest<LoginResponse>; 6 10 } -
ChapterX.Application/Auth/RegisterRequest.cs
rd300631 rb373fea 1 1 using MediatR; 2 using System.ComponentModel.DataAnnotations; 2 3 3 4 namespace ChapterX.Application.Auth 4 5 { 5 public record RegisterRequest(string Username, string Email, string Name, string Surname, string Password) : IRequest<RegisterResponse>; 6 public record RegisterRequest( 7 [Required][MaxLength(50)] string Username, 8 [Required][EmailAddress][MaxLength(200)] string Email, 9 [Required][MaxLength(100)] string Name, 10 [Required][MaxLength(100)] string Surname, 11 [Required][MinLength(8)][MaxLength(128)] string Password 12 ) : IRequest<RegisterResponse>; 6 13 } -
ChapterX.Application/Chapter/Commands/AddRequest.cs
rd300631 rb373fea 1 1 using MediatR; 2 using System.ComponentModel.DataAnnotations; 2 3 3 4 namespace ChapterX.Application.Chapter.Commands 4 5 { 5 6 public record AddRequest( 6 int Number,7 string Name,8 string Title,9 string Content,7 [Range(1, int.MaxValue)] int Number, 8 [Required][MaxLength(200)] string Name, 9 [Required][MaxLength(300)] string Title, 10 [Required] string Content, 10 11 int StoryId 11 12 ) : IRequest<AddResponse>; -
ChapterX.Application/Chapter/Commands/DeleteHandler.cs
rd300631 rb373fea 18 18 public async Task<DeleteResponse> Handle(DeleteRequest request, CancellationToken cancellationToken) 19 19 { 20 var chapter = await _chapterRepository.GetById Async(request.Id, cancellationToken);20 var chapter = await _chapterRepository.GetByIdWithStoryAsync(request.Id, cancellationToken); 21 21 if (chapter is null) 22 22 return new DeleteResponse(false); 23 24 if (chapter.Story.UserId != request.CallerId) 25 throw new UnauthorizedAccessException("You do not own this chapter."); 23 26 24 27 await _chapterRepository.DeleteAsync(chapter, cancellationToken); -
ChapterX.Application/Chapter/Commands/DeleteRequest.cs
rd300631 rb373fea 3 3 namespace ChapterX.Application.Chapter.Commands 4 4 { 5 public record DeleteRequest(int Id ) : IRequest<DeleteResponse>;5 public record DeleteRequest(int Id, int CallerId) : IRequest<DeleteResponse>; 6 6 } -
ChapterX.Application/Chapter/Commands/UpdateHandler.cs
rd300631 rb373fea 18 18 public async Task<UpdateResponse> Handle(UpdateRequest request, CancellationToken cancellationToken) 19 19 { 20 var chapter = await _chapterRepository.GetById Async(request.Id, cancellationToken);20 var chapter = await _chapterRepository.GetByIdWithStoryAsync(request.Id, cancellationToken); 21 21 if (chapter is null) 22 22 return new UpdateResponse(false); 23 24 if (chapter.Story.UserId != request.CallerId) 25 throw new UnauthorizedAccessException("You do not own this chapter."); 23 26 24 27 chapter.Number = request.Number; -
ChapterX.Application/Chapter/Commands/UpdateRequest.cs
rd300631 rb373fea 9 9 string Title, 10 10 string Content, 11 int? WordCount 11 int? WordCount, 12 int CallerId = 0 12 13 ) : IRequest<UpdateResponse>; 13 14 } -
ChapterX.Application/Comment/Commands/AddRequest.cs
rd300631 rb373fea 1 1 using MediatR; 2 using System.ComponentModel.DataAnnotations; 2 3 3 4 namespace ChapterX.Application.Comment.Commands 4 5 { 5 public record AddRequest(string Content, int UserId, int StoryId) : IRequest<AddResponse>; 6 public record AddRequest( 7 [Required][MaxLength(2000)] string Content, 8 int UserId, 9 int StoryId 10 ) : IRequest<AddResponse>; 6 11 } -
ChapterX.Application/Comment/Commands/DeleteHandler.cs
rd300631 rb373fea 22 22 return new DeleteResponse(false); 23 23 24 if (comment.UserId != request.CallerId) 25 throw new UnauthorizedAccessException("You do not own this comment."); 26 24 27 await _commentRepository.DeleteAsync(comment, cancellationToken); 25 28 -
ChapterX.Application/Comment/Commands/DeleteRequest.cs
rd300631 rb373fea 3 3 namespace ChapterX.Application.Comment.Commands 4 4 { 5 public record DeleteRequest(int Id ) : IRequest<DeleteResponse>;5 public record DeleteRequest(int Id, int CallerId) : IRequest<DeleteResponse>; 6 6 } -
ChapterX.Application/Comment/Commands/UpdateHandler.cs
rd300631 rb373fea 22 22 return new UpdateResponse(false); 23 23 24 if (comment.UserId != request.CallerId) 25 throw new UnauthorizedAccessException("You do not own this comment."); 26 24 27 comment.Content = request.Content; 25 28 comment.UpdatedAt = DateTime.UtcNow; -
ChapterX.Application/Comment/Commands/UpdateRequest.cs
rd300631 rb373fea 3 3 namespace ChapterX.Application.Comment.Commands 4 4 { 5 public record UpdateRequest(int Id, string Content ) : IRequest<UpdateResponse>;5 public record UpdateRequest(int Id, string Content, int CallerId = 0) : IRequest<UpdateResponse>; 6 6 } -
ChapterX.Application/Story/Commands/AddRequest.cs
rd300631 rb373fea 1 1 using MediatR; 2 using System.ComponentModel.DataAnnotations; 2 3 3 4 namespace ChapterX.Application.Story.Commands 4 5 { 5 public record AddRequest(bool MatureContent, string ShortDescription, string? Image, string Content, int UserId, List<string> Genres) : IRequest<AddResponse>; 6 public record AddRequest( 7 bool MatureContent, 8 [Required][MaxLength(500)] string ShortDescription, 9 [MaxLength(2048)] string? Image, 10 [Required] string Content, 11 int UserId, 12 List<string> Genres 13 ) : IRequest<AddResponse>; 6 14 } -
ChapterX.Application/Story/Commands/DeleteHandler.cs
rd300631 rb373fea 22 22 return new DeleteResponse(false); 23 23 24 if (story.UserId != request.CallerId) 25 throw new UnauthorizedAccessException("You do not own this story."); 26 24 27 await _storyRepository.DeleteAsync(story, cancellationToken); 25 28 -
ChapterX.Application/Story/Commands/DeleteRequest.cs
rd300631 rb373fea 3 3 namespace ChapterX.Application.Story.Commands 4 4 { 5 public record DeleteRequest(int Id ) : IRequest<DeleteResponse>;5 public record DeleteRequest(int Id, int CallerId) : IRequest<DeleteResponse>; 6 6 } -
ChapterX.Application/Story/Commands/UpdateHandler.cs
rd300631 rb373fea 22 22 return new UpdateResponse(false); 23 23 24 if (story.UserId != request.CallerId) 25 throw new UnauthorizedAccessException("You do not own this story."); 26 24 27 story.MatureContent = request.MatureContent; 25 28 story.ShortDescription = request.ShortDescription; -
ChapterX.Application/Story/Commands/UpdateRequest.cs
rd300631 rb373fea 3 3 namespace ChapterX.Application.Story.Commands 4 4 { 5 public record UpdateRequest(int Id, bool MatureContent, string ShortDescription, string? Image, string Content ) : IRequest<UpdateResponse>;5 public record UpdateRequest(int Id, bool MatureContent, string ShortDescription, string? Image, string Content, int CallerId = 0) : IRequest<UpdateResponse>; 6 6 }
Note:
See TracChangeset
for help on using the changeset viewer.
