Changeset e882b92


Ignore:
Timestamp:
08/24/26 20:57:09 (13 days ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Parents:
a6e33d1
Message:

Added corrected entitef from the ER diagram and changes for the logic to be coresponding to the ddl

Files:
1 added
113 deleted
59 edited
1 moved

Legend:

Unmodified
Added
Removed
  • .gitignore

    ra6e33d1 re882b92  
    1414# Environment
    1515appsettings.Development.json
     16
     17# Claude Code
     18.claude/
  • ChapterX.API/Controllers/AISuggestionsController.cs

    ra6e33d1 re882b92  
    5555                appliedAt = s.AppliedAt,
    5656                storyId = s.StoryId,
    57                 suggestionTypes = s.SuggestionTypes.Select(t => t.SuggestionTypeValue),
     57                suggestionType = s.SuggestionType,
    5858            });
    5959            return Ok(result);
  • ChapterX.API/Controllers/NotificationsController.cs

    ra6e33d1 re882b92  
    3535                isRead = n.IsRead,
    3636                createdAt = n.CreatedAt,
    37                 type = n.Type ?? "info",
     37                contentType = n.ContentType,
     38                storyId = n.StoryId,
    3839                link = n.Link,
    3940            });
  • ChapterX.API/Controllers/StoriesController.cs

    ra6e33d1 re882b92  
    3737                image = s.Image,
    3838                content = s.Content,
     39                status = s.Status,
    3940                matureContent = s.MatureContent,
    4041                createdAt = s.CreatedAt,
     
    6667                image = s.Image,
    6768                content = s.Content,
     69                status = s.Status,
    6870                matureContent = s.MatureContent,
    6971                createdAt = s.CreatedAt,
  • ChapterX.API/DTOs/AISuggestionDto.cs

    ra6e33d1 re882b92  
    66        public string OriginalText { get; set; } = string.Empty;
    77        public string SuggestedText { get; set; } = string.Empty;
     8        public string SuggestionType { get; set; } = string.Empty;
    89        public bool Accepted { get; set; }
    910        public DateTime CreatedAt { get; set; }
     
    1516        // Navigation
    1617        public StoryDto Story { get; set; } = null!;
    17         public ICollection<SuggestionTypeDto> SuggestionTypes { get; set; } = [];
    1818        public ICollection<NeedApprovalDto> NeedApprovals { get; set; } = [];
    1919    }
  • ChapterX.API/DTOs/AdminDto.cs

    ra6e33d1 re882b92  
    44    {
    55        public int UserId { get; set; }
     6        public DateTime AssignedAt { get; set; }
    67
    78        // Navigation
  • ChapterX.API/DTOs/CollaborationDto.cs

    ra6e33d1 re882b92  
    77        public int UserId { get; set; }
    88        public int StoryId { get; set; }
     9        public string Role { get; set; } = string.Empty;
     10        public int? PermissionLevel { get; set; }
    911        public DateTime CreatedAt { get; set; }
    1012
     
    1214        public UserDto User { get; set; } = null!;
    1315        public StoryDto Story { get; set; } = null!;
    14         public ICollection<RolesDto> Roles { get; set; } = [];
    15         public ICollection<PermissionLevelDto> PermissionLevels { get; set; } = [];
    1616    }
    1717}
  • ChapterX.API/DTOs/LikesDto.cs

    ra6e33d1 re882b92  
    55        public int UserId { get; set; }
    66        public int StoryId { get; set; }
    7         public DateTime CreatedAt { get; set; }
     7        public DateTime LikedAt { get; set; }
    88
    99        // Navigation
  • ChapterX.API/DTOs/NotificationDto.cs

    ra6e33d1 re882b92  
    77        public int Id { get; set; }
    88        public string Content { get; set; } = string.Empty;
     9        public string ContentType { get; set; } = string.Empty;
    910        public bool IsRead { get; set; }
     11        public string? Link { get; set; }
     12        public int UserId { get; set; }
     13        public int? StoryId { get; set; }
    1014        public DateTime CreatedAt { get; set; }
    11 
    12         // Navigation
    13         public ICollection<ContentType> ContentTypes { get; set; } = [];
    14         public ICollection<NotifyDto> Notifies { get; set; } = [];
    1515    }
    1616}
  • ChapterX.API/DTOs/RegularUserDto.cs

    ra6e33d1 re882b92  
    44    {
    55        public int UserId { get; set; }
     6        public DateTime JoinedAt { get; set; }
    67
    78        // Navigation
  • ChapterX.API/DTOs/StoryDto.cs

    ra6e33d1 re882b92  
    99        public int Id { get; set; }
    1010        public bool MatureContent { get; set; }
     11        public string Title { get; set; } = string.Empty;
    1112        public string ShortDescription { get; set; } = string.Empty;
    1213        public string? Image { get; set; }
    1314        public string Content { get; set; } = string.Empty;
     15        public string Status { get; set; } = "draft";
    1416        public DateTime CreatedAt { get; set; }
    1517        public DateTime UpdatedAt { get; set; }
     
    1921        // Navigation
    2022        public WriterDto Writer { get; set; } = null!;
    21         public ICollection<StatusDto> Statuses { get; set; } = [];
    2223        public ICollection<ChapterDto> Chapters { get; set; } = [];
    2324        public ICollection<HasGenreDto> HasGenres { get; set; } = [];
     
    2627        public ICollection<CollaborationDto> Collaborations { get; set; } = [];
    2728        public ICollection<AISuggestionDto> AISuggestions { get; set; } = [];
    28         public ICollection<NotifyDto> Notifies { get; set; } = [];
    2929        public ICollection<ReadingListItemsDto> ReadingListItems { get; set; } = [];
    3030        public ICollection<NeedApprovalDto> NeedApprovals { get; set; } = [];
  • ChapterX.API/DTOs/UserDto.cs

    ra6e33d1 re882b92  
    2323        public ICollection<CommentDto> Comments { get; set; } = [];
    2424        public ICollection<CollaborationDto> Collaborations { get; set; } = [];
    25         public ICollection<NotifyDto> Notifies { get; set; } = [];
     25        public ICollection<NotificationDto> Notifications { get; set; } = [];
    2626    }
    2727}
  • ChapterX.API/DTOs/WriterDto.cs

    ra6e33d1 re882b92  
    44    {
    55        public int UserId { get; set; }
     6        public string? Bio { get; set; }
    67
    78        // Navigation
  • ChapterX.Application/AISuggestion/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2222                OriginalText = request.OriginalText,
    2323                SuggestedText = request.SuggestedText,
     24                SuggestionType = request.SuggestionType,
    2425                StoryId = request.StoryId,
    2526                Accepted = null,
  • ChapterX.Application/AISuggestion/Commands/AddRequest.cs

    ra6e33d1 re882b92  
    66        string OriginalText,
    77        string SuggestedText,
     8        string SuggestionType,
    89        int StoryId
    910    ) : IRequest<AddResponse>;
  • ChapterX.Application/Abstractions/IApplicationDbContext.cs

    ra6e33d1 re882b92  
    1111using LikesEntity = ChapterX.Domain.Entities.Likes;
    1212using CollaborationEntity = ChapterX.Domain.Entities.Collaboration;
    13 using NotifyEntity = ChapterX.Domain.Entities.Notify;
    1413using AISuggestionEntity = ChapterX.Domain.Entities.AISuggestion;
    1514using AdminEntity = ChapterX.Domain.Entities.Admin;
     
    3332        DbSet<LikesEntity> Likes { get; }
    3433        DbSet<CollaborationEntity> Collaborations { get; }
    35         DbSet<NotifyEntity> Notifies { get; }
    3634        DbSet<AISuggestionEntity> AISuggestions { get; }
    3735        DbSet<AdminEntity> Admins { get; }
  • ChapterX.Application/Admin/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2020            var admin = new Domain.Entities.Admin
    2121            {
    22                 Id = request.UserId
     22                Id = request.UserId,
     23                AssignedAt = DateTime.UtcNow
    2324            };
    2425
  • ChapterX.Application/Collaboration/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2222                UserId = request.UserId,
    2323                StoryId = request.StoryId,
     24                Role = request.Role,
     25                PermissionLevel = request.PermissionLevel,
    2426                CreatedAt = DateTime.UtcNow
    2527            };
  • ChapterX.Application/Collaboration/Commands/AddRequest.cs

    ra6e33d1 re882b92  
    33namespace ChapterX.Application.Collaboration.Commands
    44{
    5     public record AddRequest(int UserId, int StoryId, string Role) : IRequest<AddResponse>;
     5    public record AddRequest(int UserId, int StoryId, string Role, int? PermissionLevel = null) : IRequest<AddResponse>;
    66}
  • ChapterX.Application/Collaboration/Commands/UpdateHandler.cs

    ra6e33d1 re882b92  
    2222                return new UpdateResponse(false);
    2323
    24             // No updatable fields on Collaboration entity
     24            collaboration.Role = request.Role;
     25            collaboration.PermissionLevel = request.PermissionLevel;
    2526
    2627            await _collaborationRepository.UpdateAsync(collaboration, cancellationToken);
  • ChapterX.Application/Collaboration/Commands/UpdateRequest.cs

    ra6e33d1 re882b92  
    33namespace ChapterX.Application.Collaboration.Commands
    44{
    5     public record UpdateRequest(int Id, string Role) : IRequest<UpdateResponse>;
     5    public record UpdateRequest(int Id, string Role, int? PermissionLevel = null) : IRequest<UpdateResponse>;
    66}
  • ChapterX.Application/Likes/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2222                UserId = request.UserId,
    2323                StoryId = request.StoryId,
    24                 CreatedAt = DateTime.UtcNow
     24                LikedAt = DateTime.UtcNow
    2525            };
    2626
  • ChapterX.Application/Notification/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2121            {
    2222                Content = request.Content,
     23                ContentType = request.ContentType,
    2324                IsRead = false,
     25                Link = request.Link,
     26                UserId = request.UserId,
     27                StoryId = request.StoryId,
    2428                CreatedAt = DateTime.UtcNow,
    25                 RecipientUserId = request.RecipientUserId,
    26                 Type = request.Type,
    27                 Link = request.Link,
    2829            };
    2930
  • ChapterX.Application/Notification/Commands/AddRequest.cs

    ra6e33d1 re882b92  
    33namespace ChapterX.Application.Notification.Commands
    44{
    5     public record AddRequest(string Content, int? RecipientUserId = null, string? Type = null, string? Link = null) : IRequest<AddResponse>;
     5    public record AddRequest(string Content, string ContentType, int UserId, int? StoryId = null, string? Link = null) : IRequest<AddResponse>;
    66}
  • ChapterX.Application/RegularUser/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2020            var regularUser = new Domain.Entities.RegularUser
    2121            {
    22                 Id = request.UserId
     22                Id = request.UserId,
     23                JoinedAt = DateTime.UtcNow
    2324            };
    2425
  • ChapterX.Application/Story/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    3535                    Image = request.Image,
    3636                    Content = request.Content,
     37                    Status = "draft",
    3738                    UserId = request.UserId,
    3839                    CreatedAt = DateTime.UtcNow,
  • ChapterX.Application/Story/Commands/UpdateHandler.cs

    ra6e33d1 re882b92  
    3030            story.Image = request.Image;
    3131            story.Content = request.Content;
     32            if (request.Status is not null)
     33                story.Status = request.Status;
    3234            story.UpdatedAt = DateTime.UtcNow;
    3335
  • ChapterX.Application/Story/Commands/UpdateRequest.cs

    ra6e33d1 re882b92  
    33namespace ChapterX.Application.Story.Commands
    44{
    5     public record UpdateRequest(int Id, bool MatureContent, string Title, string ShortDescription, string? Image, string Content, int CallerId = 0) : IRequest<UpdateResponse>;
     5    public record UpdateRequest(int Id, bool MatureContent, string Title, string ShortDescription, string? Image, string Content, string? Status = null, int CallerId = 0) : IRequest<UpdateResponse>;
    66}
  • ChapterX.Application/Writer/Commands/AddHandler.cs

    ra6e33d1 re882b92  
    2020            var writer = new Domain.Entities.Writer
    2121            {
    22                 Id = request.UserId
     22                Id = request.UserId,
     23                Bio = request.Bio
    2324            };
    2425
  • ChapterX.Application/Writer/Commands/UpdateHandler.cs

    ra6e33d1 re882b92  
    2222                return new UpdateResponse(false);
    2323
    24             // No updatable fields on Writer entity
     24            writer.Bio = request.Bio;
    2525
    2626            await _writerRepository.UpdateAsync(writer, cancellationToken);
  • ChapterX.Domain/DTOs/AISuggestionDto.cs

    ra6e33d1 re882b92  
    66        public string OriginalText { get; set; } = string.Empty;
    77        public string SuggestedText { get; set; } = string.Empty;
     8        public string SuggestionType { get; set; } = string.Empty;
    89        public bool Accepted { get; set; }
    910        public DateTime CreatedAt { get; set; }
     
    1516        // Navigation
    1617        public StoryDto Story { get; set; } = null!;
    17         public ICollection<SuggestionTypeDto> SuggestionTypes { get; set; } = [];
    1818        public ICollection<NeedApprovalDto> NeedApprovals { get; set; } = [];
    1919    }
  • ChapterX.Domain/DTOs/AdminDto.cs

    ra6e33d1 re882b92  
    44    {
    55        public int UserId { get; set; }
     6        public DateTime AssignedAt { get; set; }
    67
    78        // Navigation
  • ChapterX.Domain/DTOs/CollaborationDto.cs

    ra6e33d1 re882b92  
    55        public int UserId { get; set; }
    66        public int StoryId { get; set; }
     7        public string Role { get; set; } = string.Empty;
     8        public int? PermissionLevel { get; set; }
    79        public DateTime CreatedAt { get; set; }
    810
     
    1012        public UserDto User { get; set; } = null!;
    1113        public StoryDto Story { get; set; } = null!;
    12         public ICollection<RolesDto> Roles { get; set; } = [];
    13         public ICollection<PermissionLevelDto> PermissionLevels { get; set; } = [];
    1414    }
    1515}
  • ChapterX.Domain/DTOs/LikesDto.cs

    ra6e33d1 re882b92  
    55        public int UserId { get; set; }
    66        public int StoryId { get; set; }
    7         public DateTime CreatedAt { get; set; }
     7        public DateTime LikedAt { get; set; }
    88
    99        // Navigation
  • ChapterX.Domain/DTOs/NotificationDto.cs

    ra6e33d1 re882b92  
    55        public int Id { get; set; }
    66        public string Content { get; set; } = string.Empty;
     7        public string ContentType { get; set; } = string.Empty;
    78        public bool IsRead { get; set; }
     9        public string? Link { get; set; }
     10        public int UserId { get; set; }
     11        public int? StoryId { get; set; }
    812        public DateTime CreatedAt { get; set; }
    9 
    10         // Navigation
    11         public ICollection<ContentTypeDto> ContentTypes { get; set; } = [];
    12         public ICollection<NotifyDto> Notifies { get; set; } = [];
    1313    }
    1414}
  • ChapterX.Domain/DTOs/RegularUserDto.cs

    ra6e33d1 re882b92  
    44    {
    55        public int UserId { get; set; }
     6        public DateTime JoinedAt { get; set; }
    67
    78        // Navigation
  • ChapterX.Domain/DTOs/StoryDto.cs

    ra6e33d1 re882b92  
    77        public int Id { get; set; }
    88        public bool MatureContent { get; set; }
     9        public string Title { get; set; } = string.Empty;
    910        public string ShortDescription { get; set; } = string.Empty;
    1011        public string? Image { get; set; }
    1112        public string Content { get; set; } = string.Empty;
     13        public string Status { get; set; } = "draft";
    1214        public DateTime CreatedAt { get; set; }
    1315        public DateTime UpdatedAt { get; set; }
     
    1719        // Navigation
    1820        public WriterDto Writer { get; set; } = null!;
    19         public ICollection<StatusDto> Statuses { get; set; } = [];
    2021        public ICollection<ChapterDto> Chapters { get; set; } = [];
    2122        public ICollection<HasGenreDto> HasGenres { get; set; } = [];
     
    2425        public ICollection<CollaborationDto> Collaborations { get; set; } = [];
    2526        public ICollection<AISuggestionDto> AISuggestions { get; set; } = [];
    26         public ICollection<NotifyDto> Notifies { get; set; } = [];
    2727        public ICollection<ReadingListItemsDto> ReadingListItems { get; set; } = [];
    2828        public ICollection<NeedApprovalDto> NeedApprovals { get; set; } = [];
  • ChapterX.Domain/DTOs/UserDto.cs

    ra6e33d1 re882b92  
    2222        public ICollection<CommentDto> Comments { get; set; } = [];
    2323        public ICollection<CollaborationDto> Collaborations { get; set; } = [];
    24         public ICollection<NotifyDto> Notifies { get; set; } = [];
     24        public ICollection<NotificationDto> Notifications { get; set; } = [];
    2525    }
    2626}
  • ChapterX.Domain/DTOs/WriterDto.cs

    ra6e33d1 re882b92  
    66    {
    77        public int UserId { get; set; }
     8        public string? Bio { get; set; }
    89
    910        // Navigation
  • ChapterX.Domain/Entities/AISuggestion.cs

    ra6e33d1 re882b92  
    1313        public string OriginalText { get; set; } = string.Empty;
    1414        public string SuggestedText { get; set; } = string.Empty;
     15        public string SuggestionType { get; set; } = string.Empty;
    1516        public bool? Accepted { get; set; }
    1617        public DateTime CreatedAt { get; set; }
     
    1920        public int StoryId { get; set; }
    2021        public Story Story { get; set; } = null!;
    21         public ICollection<SuggestionType> SuggestionTypes { get; set; } = [];
    2222        public ICollection<NeedApproval> NeedApprovals { get; set; } = [];
    2323
  • ChapterX.Domain/Entities/Admin.cs

    ra6e33d1 re882b92  
    66    {
    77        public int Id { get; set; } // maps to user_id
     8        public DateTime AssignedAt { get; set; }
    89        public User User { get; set; } = null!;
    910    }
  • ChapterX.Domain/Entities/Collaboration.cs

    ra6e33d1 re882b92  
    88        public int UserId { get; set; }
    99        public int StoryId { get; set; }
     10        public string Role { get; set; } = string.Empty;
     11        public int? PermissionLevel { get; set; }
    1012        public DateTime CreatedAt { get; set; }
    1113        public User User { get; set; } = null!;
  • ChapterX.Domain/Entities/Likes.cs

    ra6e33d1 re882b92  
    88        public int UserId { get; set; }
    99        public int StoryId { get; set; }
    10         public DateTime CreatedAt { get; set; }
     10        public DateTime LikedAt { get; set; }
    1111        public User User { get; set; } = null!;
    1212        public Story Story { get; set; } = null!;
  • ChapterX.Domain/Entities/Notification.cs

    ra6e33d1 re882b92  
    1212        public int Id { get; set; }
    1313        public string Content { get; set; } = string.Empty;
     14        public string ContentType { get; set; } = string.Empty;
    1415        public bool IsRead { get; set; }
     16        public string? Link { get; set; }
    1517        public DateTime CreatedAt { get; set; }
    16         public int? RecipientUserId { get; set; }
    17         public string? Type { get; set; }
    18         public string? Link { get; set; }
    1918
    20         public ICollection<ContentType> ContentTypes { get; set; } = [];
    21         public ICollection<Notify> Notifies { get; set; } = [];
    22 
     19        public int UserId { get; set; }
     20        public int? StoryId { get; set; }
     21        public User User { get; set; } = null!;
     22        public Story? Story { get; set; }
    2323    }
    2424}
  • ChapterX.Domain/Entities/RegularUser.cs

    ra6e33d1 re882b92  
    66    {
    77        public int Id { get; set; } // maps to user_id
     8        public DateTime JoinedAt { get; set; }
    89        public User User { get; set; } = null!;
    910    }
  • ChapterX.Domain/Entities/Story.cs

    ra6e33d1 re882b92  
    1616        public string? Image { get; set; }
    1717        public string Content { get; set; } = string.Empty;
     18        public string Status { get; set; } = "draft";
    1819        public DateTime CreatedAt { get; set; }
    1920        public DateTime UpdatedAt { get; set; }
     
    2122        public int UserId { get; set; }
    2223        public Writer Writer { get; set; } = null!;
    23         public ICollection<Status> Statuses { get; set; } = [];
    2424        public ICollection<Chapter> Chapters { get; set; } = [];
    2525        public ICollection<HasGenre> HasGenres { get; set; } = [];
     
    2828        public ICollection<Collaboration> Collaborations { get; set; } = [];
    2929        public ICollection<AISuggestion> AISuggestions { get; set; } = [];
    30         public ICollection<Notify> Notifies { get; set; } = [];
     30        public ICollection<Notification> Notifications { get; set; } = [];
    3131        public ICollection<ReadingListItems> ReadingListItems { get; set; } = [];
    3232        public ICollection<NeedApproval> NeedApprovals { get; set; } = [];
  • ChapterX.Domain/Entities/User.cs

    ra6e33d1 re882b92  
    2626        public ICollection<Comment> Comments { get; set; } = [];
    2727        public ICollection<Collaboration> Collaborations { get; set; } = [];
    28         public ICollection<Notify> Notifies { get; set; } = [];
     28        public ICollection<Notification> Notifications { get; set; } = [];
    2929
    3030
  • ChapterX.Domain/Entities/Writer.cs

    ra6e33d1 re882b92  
    66    {
    77        public int Id { get; set; } // maps to user_id
     8        public string? Bio { get; set; }
    89        public User User { get; set; } = null!;
    910        public ICollection<Story> Stories { get; set; } = [];
  • ChapterX.Infrastructure/Data/DataContext/ApplicationDbContext.cs

    ra6e33d1 re882b92  
    1919        public DbSet<Likes> Likes { get; init; }
    2020        public DbSet<Collaboration> Collaborations { get; init; }
    21         public DbSet<Notify> Notifies { get; init; }
    2221        public DbSet<AISuggestion> AISuggestions { get; init; }
    2322        public DbSet<Admin> Admins { get; init; }
     
    2625        public DbSet<HasGenre> HasGenres { get; init; }
    2726        public DbSet<NeedApproval> NeedApprovals { get; init; }
    28         public DbSet<Status> Statuses { get; init; }
    29         public DbSet<ContentType> ContentTypes { get; init; }
    30         public DbSet<SuggestionType> SuggestionTypes { get; init; }
    31         public DbSet<Roles> Roles { get; init; }
    32         public DbSet<PermissionLevel> PermissionLevels { get; init; }
    3327
    3428        public Task<IDbContextTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default)
     
    6054                e.HasKey(x => x.Id);
    6155                e.Property(x => x.Id).HasColumnName("user_id");
     56                e.Property(x => x.AssignedAt).HasColumnName("assigned_at");
    6257                e.HasOne(x => x.User).WithOne(u => u.Admin).HasForeignKey<Admin>(x => x.Id);
    6358            });
     
    6964                e.HasKey(x => x.Id);
    7065                e.Property(x => x.Id).HasColumnName("user_id");
     66                e.Property(x => x.JoinedAt).HasColumnName("joined_at");
    7167                e.HasOne(x => x.User).WithOne(u => u.RegularUser).HasForeignKey<RegularUser>(x => x.Id);
    7268            });
     
    7874                e.HasKey(x => x.Id);
    7975                e.Property(x => x.Id).HasColumnName("user_id");
     76                e.Property(x => x.Bio).HasColumnName("bio");
    8077                e.HasOne(x => x.User).WithOne(u => u.Writer).HasForeignKey<Writer>(x => x.Id);
    8178            });
     
    9289                e.Property(x => x.Image).HasColumnName("image");
    9390                e.Property(x => x.Content).HasColumnName("story_content");
     91                e.Property(x => x.Status).HasColumnName("status");
    9492                e.Property(x => x.UserId).HasColumnName("user_id");
    9593                e.Property(x => x.CreatedAt).HasColumnName("story_created_at");
    9694                e.Property(x => x.UpdatedAt).HasColumnName("story_updated_at");
    9795                e.HasOne(x => x.Writer).WithMany(w => w.Stories).HasForeignKey(x => x.UserId);
    98             });
    99 
    100             // STATUS
    101             modelBuilder.Entity<Status>(e =>
    102             {
    103                 e.ToTable("status");
    104                 e.HasKey(x => new { x.StoryId, x.StatusValue });
    105                 e.Ignore(x => x.Id);
    106                 e.Property(x => x.StoryId).HasColumnName("story_id");
    107                 e.Property(x => x.StatusValue).HasColumnName("status");
    108                 e.HasOne(x => x.Story).WithMany(s => s.Statuses).HasForeignKey(x => x.StoryId);
    10996            });
    11097
     
    158145                e.Property(x => x.UserId).HasColumnName("user_id");
    159146                e.Property(x => x.StoryId).HasColumnName("story_id");
    160                 e.Property(x => x.CreatedAt).HasColumnName("like_created_at");
     147                e.Property(x => x.LikedAt).HasColumnName("liked_at");
    161148                e.HasOne(x => x.User).WithMany(u => u.Likes).HasForeignKey(x => x.UserId);
    162149                e.HasOne(x => x.Story).WithMany(s => s.Likes).HasForeignKey(x => x.StoryId);
     
    213200                e.Property(x => x.Id).HasColumnName("notification_id");
    214201                e.Property(x => x.Content).HasColumnName("notification_content");
     202                e.Property(x => x.ContentType).HasColumnName("content_type");
    215203                e.Property(x => x.IsRead).HasColumnName("is_read");
     204                e.Property(x => x.Link).HasColumnName("link");
     205                e.Property(x => x.UserId).HasColumnName("user_id");
     206                e.Property(x => x.StoryId).HasColumnName("story_id");
    216207                e.Property(x => x.CreatedAt).HasColumnName("notification_created_at");
    217                 e.Property(x => x.RecipientUserId).HasColumnName("recipient_user_id");
    218                 e.Property(x => x.Type).HasColumnName("type");
    219                 e.Property(x => x.Link).HasColumnName("link");
    220             });
    221 
    222             // CONTENT_TYPE
    223             modelBuilder.Entity<ContentType>(e =>
    224             {
    225                 e.ToTable("content_type");
    226                 e.HasKey(x => new { x.NotificationId, x.ContentTypeValue });
    227                 e.Ignore(x => x.Id);
    228                 e.Property(x => x.NotificationId).HasColumnName("notification_id");
    229                 e.Property(x => x.ContentTypeValue).HasColumnName("content_type");
    230                 e.HasOne(x => x.Notification).WithMany(n => n.ContentTypes).HasForeignKey(x => x.NotificationId);
    231             });
    232 
    233             // NOTIFY
    234             modelBuilder.Entity<Notify>(e =>
    235             {
    236                 e.ToTable("notify");
    237                 e.HasKey(x => new { x.UserId, x.StoryId, x.NotificationId });
    238                 e.Ignore(x => x.Id);
    239                 e.Property(x => x.UserId).HasColumnName("user_id");
    240                 e.Property(x => x.StoryId).HasColumnName("story_id");
    241                 e.Property(x => x.NotificationId).HasColumnName("notification_id");
    242                 e.HasOne(x => x.User).WithMany(u => u.Notifies).HasForeignKey(x => x.UserId);
    243                 e.HasOne(x => x.Story).WithMany(s => s.Notifies).HasForeignKey(x => x.StoryId);
    244                 e.HasOne(x => x.Notification).WithMany(n => n.Notifies).HasForeignKey(x => x.NotificationId);
     208                e.HasOne(x => x.User).WithMany(u => u.Notifications).HasForeignKey(x => x.UserId);
     209                e.HasOne(x => x.Story).WithMany(s => s.Notifications).HasForeignKey(x => x.StoryId)
     210                    .IsRequired(false).OnDelete(DeleteBehavior.SetNull);
    245211            });
    246212
     
    253219                e.Property(x => x.OriginalText).HasColumnName("original_text");
    254220                e.Property(x => x.SuggestedText).HasColumnName("suggested_text");
     221                e.Property(x => x.SuggestionType).HasColumnName("suggestion_type");
    255222                e.Property(x => x.Accepted).HasColumnName("accepted");
    256223                e.Property(x => x.CreatedAt).HasColumnName("suggestion_created_at");
     
    258225                e.Property(x => x.StoryId).HasColumnName("story_id");
    259226                e.HasOne(x => x.Story).WithMany(s => s.AISuggestions).HasForeignKey(x => x.StoryId);
    260             });
    261 
    262             // SUGGESTION_TYPE
    263             modelBuilder.Entity<SuggestionType>(e =>
    264             {
    265                 e.ToTable("suggestion_type");
    266                 e.HasKey(x => new { x.SuggestionId, x.SuggestionTypeValue });
    267                 e.Ignore(x => x.Id);
    268                 e.Property(x => x.SuggestionId).HasColumnName("suggestion_id");
    269                 e.Property(x => x.SuggestionTypeValue).HasColumnName("suggestion_type");
    270                 e.HasOne(x => x.AISuggestion).WithMany(a => a.SuggestionTypes).HasForeignKey(x => x.SuggestionId);
    271227            });
    272228
     
    293249                e.Property(x => x.UserId).HasColumnName("user_id");
    294250                e.Property(x => x.StoryId).HasColumnName("story_id");
     251                e.Property(x => x.Role).HasColumnName("role");
     252                e.Property(x => x.PermissionLevel).HasColumnName("permission_level");
    295253                e.Property(x => x.CreatedAt).HasColumnName("collab_created_at");
    296254                e.HasOne(x => x.User).WithMany(u => u.Collaborations).HasForeignKey(x => x.UserId);
    297255                e.HasOne(x => x.Story).WithMany(s => s.Collaborations).HasForeignKey(x => x.StoryId);
    298256            });
    299 
    300             // ROLES
    301             modelBuilder.Entity<Roles>(e =>
    302             {
    303                 e.ToTable("roles");
    304                 e.HasKey(x => new { x.UserId, x.StoryId, x.RoleValue });
    305                 e.Ignore(x => x.Id);
    306                 e.Property(x => x.UserId).HasColumnName("user_id");
    307                 e.Property(x => x.StoryId).HasColumnName("story_id");
    308                 e.Property(x => x.RoleValue).HasColumnName("roles");
    309             });
    310 
    311             // PERMISSION_LEVEL
    312             modelBuilder.Entity<PermissionLevel>(e =>
    313             {
    314                 e.ToTable("permission_level");
    315                 e.HasKey(x => new { x.UserId, x.StoryId, x.Level });
    316                 e.Ignore(x => x.Id);
    317                 e.Property(x => x.UserId).HasColumnName("user_id");
    318                 e.Property(x => x.StoryId).HasColumnName("story_id");
    319                 e.Property(x => x.Level).HasColumnName("permission_level");
    320             });
    321257        }
    322258    }
  • ChapterX.Infrastructure/DependencyInjection.cs

    ra6e33d1 re882b92  
    4444            services.AddScoped<IReadingListItemsRepository, ReadingListItemsRepository>();
    4545            services.AddScoped<INotificationRepository, NotificationRepository>();
    46             services.AddScoped<INotifyRepository, NotifyRepository>();
    4746            services.AddScoped<INeedApprovalRepository, NeedApprovalRepository>();
    4847            services.AddScoped<ILikesRepository, LikesRepository>();
     
    5251            services.AddScoped<ICommentRepository, CommentRepository>();
    5352            services.AddScoped<IAISuggestionRepository, AISuggestionRepository>();
    54             services.AddScoped<IContentTypeRepository, ContentTypeRepository>();
    55             services.AddScoped<IPermissionLevelRepository, PermissionLevelRepository>();
    56             services.AddScoped<IRolesRepository, RolesRepository>();
    57             services.AddScoped<IStatusRepository, StatusRepository>();
    5853
    5954            return services;
  • ChapterX.Infrastructure/Migrations/20260824172555_InitialCreate.Designer.cs

    ra6e33d1 re882b92  
    1313{
    1414    [DbContext(typeof(ApplicationDbContext))]
    15     [Migration("20260319165332_InitialCreate")]
     15    [Migration("20260824172555_InitialCreate")]
    1616    partial class InitialCreate
    1717    {
     
    3030                    b.Property<int>("Id")
    3131                        .ValueGeneratedOnAdd()
    32                         .HasColumnType("integer");
     32                        .HasColumnType("integer")
     33                        .HasColumnName("suggestion_id");
    3334
    3435                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    3536
    36                     b.Property<bool>("Accepted")
    37                         .HasColumnType("boolean");
     37                    b.Property<bool?>("Accepted")
     38                        .HasColumnType("boolean")
     39                        .HasColumnName("accepted");
    3840
    3941                    b.Property<DateTime?>("AppliedAt")
    40                         .HasColumnType("timestamp with time zone");
     42                        .HasColumnType("timestamp with time zone")
     43                        .HasColumnName("applied_at");
    4144
    4245                    b.Property<DateTime>("CreatedAt")
    43                         .HasColumnType("timestamp with time zone");
     46                        .HasColumnType("timestamp with time zone")
     47                        .HasColumnName("suggestion_created_at");
    4448
    4549                    b.Property<string>("OriginalText")
    4650                        .IsRequired()
    47                         .HasColumnType("text");
     51                        .HasColumnType("text")
     52                        .HasColumnName("original_text");
    4853
    4954                    b.Property<int>("StoryId")
    50                         .HasColumnType("integer");
     55                        .HasColumnType("integer")
     56                        .HasColumnName("story_id");
    5157
    5258                    b.Property<string>("SuggestedText")
    5359                        .IsRequired()
    54                         .HasColumnType("text");
    55 
    56                     b.PrimitiveCollection<int[]>("SuggestionTypes")
    57                         .IsRequired()
    58                         .HasColumnType("integer[]");
     60                        .HasColumnType("text")
     61                        .HasColumnName("suggested_text");
     62
     63                    b.Property<string>("SuggestionType")
     64                        .IsRequired()
     65                        .HasColumnType("text")
     66                        .HasColumnName("suggestion_type");
    5967
    6068                    b.HasKey("Id");
     
    6270                    b.HasIndex("StoryId");
    6371
    64                     b.ToTable("AISuggestions");
     72                    b.ToTable("ai_suggestion", (string)null);
    6573                });
    6674
     
    6876                {
    6977                    b.Property<int>("Id")
     78                        .HasColumnType("integer")
     79                        .HasColumnName("user_id");
     80
     81                    b.Property<DateTime>("AssignedAt")
     82                        .HasColumnType("timestamp with time zone")
     83                        .HasColumnName("assigned_at");
     84
     85                    b.HasKey("Id");
     86
     87                    b.ToTable("admins", (string)null);
     88                });
     89
     90            modelBuilder.Entity("ChapterX.Domain.Entities.Chapter", b =>
     91                {
     92                    b.Property<int>("Id")
    7093                        .ValueGeneratedOnAdd()
    71                         .HasColumnType("integer");
     94                        .HasColumnType("integer")
     95                        .HasColumnName("chapter_id");
    7296
    7397                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    7498
     99                    b.Property<string>("Content")
     100                        .IsRequired()
     101                        .HasColumnType("text")
     102                        .HasColumnName("chapter_content");
     103
     104                    b.Property<DateTime>("CreatedAt")
     105                        .HasColumnType("timestamp with time zone")
     106                        .HasColumnName("chapter_created_at");
     107
     108                    b.Property<string>("Name")
     109                        .IsRequired()
     110                        .HasColumnType("text")
     111                        .HasColumnName("chapter_name");
     112
     113                    b.Property<int>("Number")
     114                        .HasColumnType("integer")
     115                        .HasColumnName("chapter_number");
     116
     117                    b.Property<DateTime>("PublishedAt")
     118                        .HasColumnType("timestamp with time zone")
     119                        .HasColumnName("published_at");
     120
     121                    b.Property<decimal?>("Rating")
     122                        .HasColumnType("numeric")
     123                        .HasColumnName("rating");
     124
     125                    b.Property<int>("StoryId")
     126                        .HasColumnType("integer")
     127                        .HasColumnName("story_id");
     128
     129                    b.Property<string>("Title")
     130                        .IsRequired()
     131                        .HasColumnType("text")
     132                        .HasColumnName("title");
     133
     134                    b.Property<DateTime>("UpdatedAt")
     135                        .HasColumnType("timestamp with time zone")
     136                        .HasColumnName("chapter_updated_at");
     137
     138                    b.Property<int>("ViewCount")
     139                        .HasColumnType("integer")
     140                        .HasColumnName("view_count");
     141
     142                    b.Property<int?>("WordCount")
     143                        .HasColumnType("integer")
     144                        .HasColumnName("word_count");
     145
     146                    b.HasKey("Id");
     147
     148                    b.HasIndex("StoryId");
     149
     150                    b.ToTable("chapter", (string)null);
     151                });
     152
     153            modelBuilder.Entity("ChapterX.Domain.Entities.Collaboration", b =>
     154                {
    75155                    b.Property<int>("UserId")
    76                         .HasColumnType("integer");
    77 
    78                     b.HasKey("Id");
    79 
    80                     b.HasIndex("UserId")
    81                         .IsUnique();
    82 
    83                     b.ToTable("Admins");
    84                 });
    85 
    86             modelBuilder.Entity("ChapterX.Domain.Entities.Chapter", b =>
     156                        .HasColumnType("integer")
     157                        .HasColumnName("user_id");
     158
     159                    b.Property<int>("StoryId")
     160                        .HasColumnType("integer")
     161                        .HasColumnName("story_id");
     162
     163                    b.Property<DateTime>("CreatedAt")
     164                        .HasColumnType("timestamp with time zone")
     165                        .HasColumnName("collab_created_at");
     166
     167                    b.Property<int?>("PermissionLevel")
     168                        .HasColumnType("integer")
     169                        .HasColumnName("permission_level");
     170
     171                    b.Property<string>("Role")
     172                        .IsRequired()
     173                        .HasColumnType("text")
     174                        .HasColumnName("role");
     175
     176                    b.HasKey("UserId", "StoryId");
     177
     178                    b.HasIndex("StoryId");
     179
     180                    b.ToTable("collaboration", (string)null);
     181                });
     182
     183            modelBuilder.Entity("ChapterX.Domain.Entities.Comment", b =>
    87184                {
    88185                    b.Property<int>("Id")
    89186                        .ValueGeneratedOnAdd()
    90                         .HasColumnType("integer");
     187                        .HasColumnType("integer")
     188                        .HasColumnName("comment_id");
    91189
    92190                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     
    94192                    b.Property<string>("Content")
    95193                        .IsRequired()
    96                         .HasColumnType("text");
     194                        .HasColumnType("text")
     195                        .HasColumnName("comment_content");
    97196
    98197                    b.Property<DateTime>("CreatedAt")
    99                         .HasColumnType("timestamp with time zone");
     198                        .HasColumnType("timestamp with time zone")
     199                        .HasColumnName("comment_created_at");
     200
     201                    b.Property<int>("StoryId")
     202                        .HasColumnType("integer")
     203                        .HasColumnName("story_id");
     204
     205                    b.Property<DateTime>("UpdatedAt")
     206                        .HasColumnType("timestamp with time zone")
     207                        .HasColumnName("comment_updated_at");
     208
     209                    b.Property<int>("UserId")
     210                        .HasColumnType("integer")
     211                        .HasColumnName("user_id");
     212
     213                    b.HasKey("Id");
     214
     215                    b.HasIndex("StoryId");
     216
     217                    b.HasIndex("UserId");
     218
     219                    b.ToTable("comment", (string)null);
     220                });
     221
     222            modelBuilder.Entity("ChapterX.Domain.Entities.Genre", b =>
     223                {
     224                    b.Property<int>("Id")
     225                        .ValueGeneratedOnAdd()
     226                        .HasColumnType("integer")
     227                        .HasColumnName("genre_id");
     228
     229                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    100230
    101231                    b.Property<string>("Name")
    102232                        .IsRequired()
    103                         .HasColumnType("text");
    104 
    105                     b.Property<int>("Number")
    106                         .HasColumnType("integer");
    107 
    108                     b.Property<DateTime>("PublishedAt")
    109                         .HasColumnType("timestamp with time zone");
    110 
    111                     b.Property<decimal?>("Rating")
    112                         .HasColumnType("numeric");
    113 
     233                        .HasColumnType("text")
     234                        .HasColumnName("genre_name");
     235
     236                    b.HasKey("Id");
     237
     238                    b.ToTable("genre", (string)null);
     239                });
     240
     241            modelBuilder.Entity("ChapterX.Domain.Entities.HasGenre", b =>
     242                {
    114243                    b.Property<int>("StoryId")
    115                         .HasColumnType("integer");
     244                        .HasColumnType("integer")
     245                        .HasColumnName("story_id");
     246
     247                    b.Property<int>("GenreId")
     248                        .HasColumnType("integer")
     249                        .HasColumnName("genre_id");
     250
     251                    b.HasKey("StoryId", "GenreId");
     252
     253                    b.HasIndex("GenreId");
     254
     255                    b.ToTable("has_genre", (string)null);
     256                });
     257
     258            modelBuilder.Entity("ChapterX.Domain.Entities.Likes", b =>
     259                {
     260                    b.Property<int>("UserId")
     261                        .HasColumnType("integer")
     262                        .HasColumnName("user_id");
     263
     264                    b.Property<int>("StoryId")
     265                        .HasColumnType("integer")
     266                        .HasColumnName("story_id");
     267
     268                    b.Property<DateTime>("LikedAt")
     269                        .HasColumnType("timestamp with time zone")
     270                        .HasColumnName("liked_at");
     271
     272                    b.HasKey("UserId", "StoryId");
     273
     274                    b.HasIndex("StoryId");
     275
     276                    b.ToTable("likes", (string)null);
     277                });
     278
     279            modelBuilder.Entity("ChapterX.Domain.Entities.NeedApproval", b =>
     280                {
     281                    b.Property<int>("SuggestionId")
     282                        .HasColumnType("integer")
     283                        .HasColumnName("suggestion_id");
     284
     285                    b.Property<int>("StoryId")
     286                        .HasColumnType("integer")
     287                        .HasColumnName("story_id");
     288
     289                    b.Property<int>("ChapterId")
     290                        .HasColumnType("integer")
     291                        .HasColumnName("chapter_id");
     292
     293                    b.HasKey("SuggestionId", "StoryId", "ChapterId");
     294
     295                    b.HasIndex("ChapterId");
     296
     297                    b.HasIndex("StoryId");
     298
     299                    b.ToTable("need_approval", (string)null);
     300                });
     301
     302            modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
     303                {
     304                    b.Property<int>("Id")
     305                        .ValueGeneratedOnAdd()
     306                        .HasColumnType("integer")
     307                        .HasColumnName("notification_id");
     308
     309                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     310
     311                    b.Property<string>("Content")
     312                        .IsRequired()
     313                        .HasColumnType("text")
     314                        .HasColumnName("notification_content");
     315
     316                    b.Property<string>("ContentType")
     317                        .IsRequired()
     318                        .HasColumnType("text")
     319                        .HasColumnName("content_type");
     320
     321                    b.Property<DateTime>("CreatedAt")
     322                        .HasColumnType("timestamp with time zone")
     323                        .HasColumnName("notification_created_at");
     324
     325                    b.Property<bool>("IsRead")
     326                        .HasColumnType("boolean")
     327                        .HasColumnName("is_read");
     328
     329                    b.Property<string>("Link")
     330                        .HasColumnType("text")
     331                        .HasColumnName("link");
     332
     333                    b.Property<int?>("StoryId")
     334                        .HasColumnType("integer")
     335                        .HasColumnName("story_id");
     336
     337                    b.Property<int>("UserId")
     338                        .HasColumnType("integer")
     339                        .HasColumnName("user_id");
     340
     341                    b.HasKey("Id");
     342
     343                    b.HasIndex("StoryId");
     344
     345                    b.HasIndex("UserId");
     346
     347                    b.ToTable("notification", (string)null);
     348                });
     349
     350            modelBuilder.Entity("ChapterX.Domain.Entities.ReadingList", b =>
     351                {
     352                    b.Property<int>("Id")
     353                        .ValueGeneratedOnAdd()
     354                        .HasColumnType("integer")
     355                        .HasColumnName("list_id");
     356
     357                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     358
     359                    b.Property<string>("Content")
     360                        .HasColumnType("text")
     361                        .HasColumnName("list_content");
     362
     363                    b.Property<DateTime>("CreatedAt")
     364                        .HasColumnType("timestamp with time zone")
     365                        .HasColumnName("list_created_at");
     366
     367                    b.Property<bool>("IsPublic")
     368                        .HasColumnType("boolean")
     369                        .HasColumnName("is_public");
     370
     371                    b.Property<string>("Name")
     372                        .IsRequired()
     373                        .HasColumnType("text")
     374                        .HasColumnName("list_name");
     375
     376                    b.Property<DateTime>("UpdatedAt")
     377                        .HasColumnType("timestamp with time zone")
     378                        .HasColumnName("list_updated_at");
     379
     380                    b.Property<int>("UserId")
     381                        .HasColumnType("integer")
     382                        .HasColumnName("user_id");
     383
     384                    b.HasKey("Id");
     385
     386                    b.HasIndex("UserId");
     387
     388                    b.ToTable("reading_list", (string)null);
     389                });
     390
     391            modelBuilder.Entity("ChapterX.Domain.Entities.ReadingListItems", b =>
     392                {
     393                    b.Property<int>("ListId")
     394                        .HasColumnType("integer")
     395                        .HasColumnName("list_id");
     396
     397                    b.Property<int>("StoryId")
     398                        .HasColumnType("integer")
     399                        .HasColumnName("story_id");
     400
     401                    b.Property<DateTime>("AddedAt")
     402                        .HasColumnType("timestamp with time zone")
     403                        .HasColumnName("added_at");
     404
     405                    b.HasKey("ListId", "StoryId");
     406
     407                    b.HasIndex("StoryId");
     408
     409                    b.ToTable("reading_list_items", (string)null);
     410                });
     411
     412            modelBuilder.Entity("ChapterX.Domain.Entities.RegularUser", b =>
     413                {
     414                    b.Property<int>("Id")
     415                        .HasColumnType("integer")
     416                        .HasColumnName("user_id");
     417
     418                    b.Property<DateTime>("JoinedAt")
     419                        .HasColumnType("timestamp with time zone")
     420                        .HasColumnName("joined_at");
     421
     422                    b.HasKey("Id");
     423
     424                    b.ToTable("regular_user", (string)null);
     425                });
     426
     427            modelBuilder.Entity("ChapterX.Domain.Entities.Story", b =>
     428                {
     429                    b.Property<int>("Id")
     430                        .ValueGeneratedOnAdd()
     431                        .HasColumnType("integer")
     432                        .HasColumnName("story_id");
     433
     434                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     435
     436                    b.Property<string>("Content")
     437                        .IsRequired()
     438                        .HasColumnType("text")
     439                        .HasColumnName("story_content");
     440
     441                    b.Property<DateTime>("CreatedAt")
     442                        .HasColumnType("timestamp with time zone")
     443                        .HasColumnName("story_created_at");
     444
     445                    b.Property<string>("Image")
     446                        .HasColumnType("text")
     447                        .HasColumnName("image");
     448
     449                    b.Property<bool>("MatureContent")
     450                        .HasColumnType("boolean")
     451                        .HasColumnName("mature_content");
     452
     453                    b.Property<string>("ShortDescription")
     454                        .IsRequired()
     455                        .HasColumnType("text")
     456                        .HasColumnName("short_description");
     457
     458                    b.Property<string>("Status")
     459                        .IsRequired()
     460                        .HasColumnType("text")
     461                        .HasColumnName("status");
    116462
    117463                    b.Property<string>("Title")
    118464                        .IsRequired()
    119                         .HasColumnType("text");
     465                        .HasColumnType("text")
     466                        .HasColumnName("title");
    120467
    121468                    b.Property<DateTime>("UpdatedAt")
    122                         .HasColumnType("timestamp with time zone");
    123 
    124                     b.Property<int>("ViewCount")
    125                         .HasColumnType("integer");
    126 
    127                     b.Property<int?>("WordCount")
    128                         .HasColumnType("integer");
    129 
    130                     b.HasKey("Id");
    131 
    132                     b.HasIndex("StoryId");
    133 
    134                     b.ToTable("Chapters");
    135                 });
    136 
    137             modelBuilder.Entity("ChapterX.Domain.Entities.Collaboration", b =>
     469                        .HasColumnType("timestamp with time zone")
     470                        .HasColumnName("story_updated_at");
     471
     472                    b.Property<int>("UserId")
     473                        .HasColumnType("integer")
     474                        .HasColumnName("user_id");
     475
     476                    b.HasKey("Id");
     477
     478                    b.HasIndex("UserId");
     479
     480                    b.ToTable("story", (string)null);
     481                });
     482
     483            modelBuilder.Entity("ChapterX.Domain.Entities.User", b =>
    138484                {
    139485                    b.Property<int>("Id")
    140486                        .ValueGeneratedOnAdd()
    141                         .HasColumnType("integer");
     487                        .HasColumnType("integer")
     488                        .HasColumnName("user_id");
    142489
    143490                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    144491
    145                     b.Property<DateTime>("JoinedAt")
    146                         .HasColumnType("timestamp with time zone");
    147 
    148                     b.Property<string>("Role")
    149                         .IsRequired()
    150                         .HasColumnType("text");
    151 
    152                     b.Property<int>("StoryId")
    153                         .HasColumnType("integer");
    154 
    155                     b.Property<int>("UserId")
    156                         .HasColumnType("integer");
    157 
    158                     b.HasKey("Id");
    159 
    160                     b.HasIndex("StoryId");
    161 
    162                     b.HasIndex("UserId");
    163 
    164                     b.ToTable("Collaborations");
    165                 });
    166 
    167             modelBuilder.Entity("ChapterX.Domain.Entities.Comment", b =>
    168                 {
    169                     b.Property<int>("Id")
    170                         .ValueGeneratedOnAdd()
    171                         .HasColumnType("integer");
    172 
    173                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    174 
    175                     b.Property<string>("Content")
    176                         .IsRequired()
    177                         .HasColumnType("text");
    178 
    179492                    b.Property<DateTime>("CreatedAt")
    180                         .HasColumnType("timestamp with time zone");
    181 
    182                     b.Property<int>("StoryId")
    183                         .HasColumnType("integer");
     493                        .HasColumnType("timestamp with time zone")
     494                        .HasColumnName("user_created_at");
     495
     496                    b.Property<string>("Email")
     497                        .IsRequired()
     498                        .HasColumnType("text")
     499                        .HasColumnName("email");
     500
     501                    b.Property<string>("Name")
     502                        .IsRequired()
     503                        .HasColumnType("text")
     504                        .HasColumnName("user_name");
     505
     506                    b.Property<string>("Password")
     507                        .IsRequired()
     508                        .HasColumnType("text")
     509                        .HasColumnName("password");
     510
     511                    b.Property<string>("Surname")
     512                        .IsRequired()
     513                        .HasColumnType("text")
     514                        .HasColumnName("surname");
    184515
    185516                    b.Property<DateTime>("UpdatedAt")
    186                         .HasColumnType("timestamp with time zone");
    187 
    188                     b.Property<int>("UserId")
    189                         .HasColumnType("integer");
    190 
    191                     b.HasKey("Id");
    192 
    193                     b.HasIndex("StoryId");
    194 
    195                     b.HasIndex("UserId");
    196 
    197                     b.ToTable("Comments");
    198                 });
    199 
    200             modelBuilder.Entity("ChapterX.Domain.Entities.Genre", b =>
    201                 {
    202                     b.Property<int>("Id")
    203                         .ValueGeneratedOnAdd()
    204                         .HasColumnType("integer");
    205 
    206                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    207 
    208                     b.Property<string>("Name")
    209                         .IsRequired()
    210                         .HasColumnType("text");
    211 
    212                     b.HasKey("Id");
    213 
    214                     b.ToTable("Genres");
    215                 });
    216 
    217             modelBuilder.Entity("ChapterX.Domain.Entities.HasGenre", b =>
    218                 {
    219                     b.Property<int>("Id")
    220                         .ValueGeneratedOnAdd()
    221                         .HasColumnType("integer");
    222 
    223                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    224 
    225                     b.Property<int>("GenreId")
    226                         .HasColumnType("integer");
    227 
    228                     b.Property<int>("StoryId")
    229                         .HasColumnType("integer");
    230 
    231                     b.HasKey("Id");
    232 
    233                     b.HasIndex("GenreId");
    234 
    235                     b.HasIndex("StoryId");
    236 
    237                     b.ToTable("HasGenres");
    238                 });
    239 
    240             modelBuilder.Entity("ChapterX.Domain.Entities.Likes", b =>
    241                 {
    242                     b.Property<int>("Id")
    243                         .ValueGeneratedOnAdd()
    244                         .HasColumnType("integer");
    245 
    246                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    247 
    248                     b.Property<int>("ChapterId")
    249                         .HasColumnType("integer");
    250 
    251                     b.Property<DateTime>("CreatedAt")
    252                         .HasColumnType("timestamp with time zone");
    253 
    254                     b.Property<int?>("StoryId")
    255                         .HasColumnType("integer");
    256 
    257                     b.Property<int>("UserId")
    258                         .HasColumnType("integer");
    259 
    260                     b.HasKey("Id");
    261 
    262                     b.HasIndex("ChapterId");
    263 
    264                     b.HasIndex("StoryId");
    265 
    266                     b.HasIndex("UserId");
    267 
    268                     b.ToTable("Likes");
    269                 });
    270 
    271             modelBuilder.Entity("ChapterX.Domain.Entities.NeedApproval", b =>
    272                 {
    273                     b.Property<int>("Id")
    274                         .ValueGeneratedOnAdd()
    275                         .HasColumnType("integer");
    276 
    277                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    278 
    279                     b.Property<int?>("AISuggestionId")
    280                         .HasColumnType("integer");
    281 
    282                     b.Property<int>("AdminId")
    283                         .HasColumnType("integer");
    284 
    285                     b.Property<bool>("Approved")
    286                         .HasColumnType("boolean");
    287 
    288                     b.Property<int?>("ChapterId")
    289                         .HasColumnType("integer");
    290 
    291                     b.Property<DateTime>("RequestedAt")
    292                         .HasColumnType("timestamp with time zone");
    293 
    294                     b.Property<int>("StoryId")
    295                         .HasColumnType("integer");
    296 
    297                     b.HasKey("Id");
    298 
    299                     b.HasIndex("AISuggestionId");
    300 
    301                     b.HasIndex("AdminId");
    302 
    303                     b.HasIndex("ChapterId");
    304 
    305                     b.HasIndex("StoryId");
    306 
    307                     b.ToTable("NeedApprovals");
    308                 });
    309 
    310             modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
    311                 {
    312                     b.Property<int>("Id")
    313                         .ValueGeneratedOnAdd()
    314                         .HasColumnType("integer");
    315 
    316                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    317 
    318                     b.Property<string>("Content")
    319                         .IsRequired()
    320                         .HasColumnType("text");
    321 
    322                     b.PrimitiveCollection<int[]>("ContentTypes")
    323                         .IsRequired()
    324                         .HasColumnType("integer[]");
    325 
    326                     b.Property<DateTime>("CreatedAt")
    327                         .HasColumnType("timestamp with time zone");
    328 
    329                     b.Property<bool>("IsRead")
    330                         .HasColumnType("boolean");
    331 
    332                     b.HasKey("Id");
    333 
    334                     b.ToTable("Notifications");
    335                 });
    336 
    337             modelBuilder.Entity("ChapterX.Domain.Entities.Notify", b =>
    338                 {
    339                     b.Property<int>("Id")
    340                         .ValueGeneratedOnAdd()
    341                         .HasColumnType("integer");
    342 
    343                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    344 
    345                     b.Property<bool>("IsRead")
    346                         .HasColumnType("boolean");
    347 
    348                     b.Property<int>("NotificationId")
    349                         .HasColumnType("integer");
    350 
    351                     b.Property<int?>("StoryId")
    352                         .HasColumnType("integer");
    353 
    354                     b.Property<int>("UserId")
    355                         .HasColumnType("integer");
    356 
    357                     b.HasKey("Id");
    358 
    359                     b.HasIndex("NotificationId");
    360 
    361                     b.HasIndex("StoryId");
    362 
    363                     b.HasIndex("UserId");
    364 
    365                     b.ToTable("Notifies");
    366                 });
    367 
    368             modelBuilder.Entity("ChapterX.Domain.Entities.ReadingList", b =>
    369                 {
    370                     b.Property<int>("Id")
    371                         .ValueGeneratedOnAdd()
    372                         .HasColumnType("integer");
    373 
    374                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    375 
    376                     b.Property<string>("Content")
    377                         .HasColumnType("text");
    378 
    379                     b.Property<DateTime>("CreatedAt")
    380                         .HasColumnType("timestamp with time zone");
    381 
    382                     b.Property<bool>("IsPublic")
    383                         .HasColumnType("boolean");
    384 
    385                     b.Property<string>("Name")
    386                         .IsRequired()
    387                         .HasColumnType("text");
    388 
    389                     b.Property<DateTime>("UpdatedAt")
    390                         .HasColumnType("timestamp with time zone");
    391 
    392                     b.Property<int>("UserId")
    393                         .HasColumnType("integer");
    394 
    395                     b.HasKey("Id");
    396 
    397                     b.HasIndex("UserId");
    398 
    399                     b.ToTable("ReadingLists");
    400                 });
    401 
    402             modelBuilder.Entity("ChapterX.Domain.Entities.ReadingListItems", b =>
    403                 {
    404                     b.Property<int>("Id")
    405                         .ValueGeneratedOnAdd()
    406                         .HasColumnType("integer");
    407 
    408                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    409 
    410                     b.Property<DateTime>("AddedAt")
    411                         .HasColumnType("timestamp with time zone");
    412 
    413                     b.Property<int>("ReadingListId")
    414                         .HasColumnType("integer");
    415 
    416                     b.Property<int>("StoryId")
    417                         .HasColumnType("integer");
    418 
    419                     b.HasKey("Id");
    420 
    421                     b.HasIndex("ReadingListId");
    422 
    423                     b.HasIndex("StoryId");
    424 
    425                     b.ToTable("ReadingListItems");
    426                 });
    427 
    428             modelBuilder.Entity("ChapterX.Domain.Entities.RegularUser", b =>
    429                 {
    430                     b.Property<int>("Id")
    431                         .ValueGeneratedOnAdd()
    432                         .HasColumnType("integer");
    433 
    434                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    435 
    436                     b.Property<int>("UserId")
    437                         .HasColumnType("integer");
    438 
    439                     b.HasKey("Id");
    440 
    441                     b.HasIndex("UserId")
    442                         .IsUnique();
    443 
    444                     b.ToTable("RegularUsers");
    445                 });
    446 
    447             modelBuilder.Entity("ChapterX.Domain.Entities.Story", b =>
    448                 {
    449                     b.Property<int>("Id")
    450                         .ValueGeneratedOnAdd()
    451                         .HasColumnType("integer");
    452 
    453                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    454 
    455                     b.Property<string>("Content")
    456                         .IsRequired()
    457                         .HasColumnType("text");
    458 
    459                     b.Property<DateTime>("CreatedAt")
    460                         .HasColumnType("timestamp with time zone");
    461 
    462                     b.Property<string>("Image")
    463                         .HasColumnType("text");
    464 
    465                     b.Property<bool>("MatureContent")
    466                         .HasColumnType("boolean");
    467 
    468                     b.Property<string>("ShortDescription")
    469                         .IsRequired()
    470                         .HasColumnType("text");
    471 
    472                     b.PrimitiveCollection<int[]>("Statuses")
    473                         .IsRequired()
    474                         .HasColumnType("integer[]");
    475 
    476                     b.Property<DateTime>("UpdatedAt")
    477                         .HasColumnType("timestamp with time zone");
    478 
    479                     b.Property<int>("UserId")
    480                         .HasColumnType("integer");
    481 
    482                     b.Property<int>("WriterId")
    483                         .HasColumnType("integer");
    484 
    485                     b.HasKey("Id");
    486 
    487                     b.HasIndex("WriterId");
    488 
    489                     b.ToTable("Stories");
    490                 });
    491 
    492             modelBuilder.Entity("ChapterX.Domain.Entities.User", b =>
    493                 {
    494                     b.Property<int>("Id")
    495                         .ValueGeneratedOnAdd()
    496                         .HasColumnType("integer");
    497 
    498                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    499 
    500                     b.Property<DateTime>("CreatedAt")
    501                         .HasColumnType("timestamp with time zone");
    502 
    503                     b.Property<string>("Email")
    504                         .IsRequired()
    505                         .HasColumnType("text");
    506 
    507                     b.Property<string>("Name")
    508                         .IsRequired()
    509                         .HasColumnType("text");
    510 
    511                     b.Property<string>("Password")
    512                         .IsRequired()
    513                         .HasColumnType("text");
    514 
    515                     b.Property<string>("Surname")
    516                         .IsRequired()
    517                         .HasColumnType("text");
    518 
    519                     b.Property<DateTime>("UpdatedAt")
    520                         .HasColumnType("timestamp with time zone");
     517                        .HasColumnType("timestamp with time zone")
     518                        .HasColumnName("user_updated_at");
    521519
    522520                    b.Property<string>("Username")
    523521                        .IsRequired()
    524                         .HasColumnType("text");
    525 
    526                     b.HasKey("Id");
    527 
    528                     b.ToTable("Users");
     522                        .HasColumnType("text")
     523                        .HasColumnName("username");
     524
     525                    b.HasKey("Id");
     526
     527                    b.ToTable("users", (string)null);
    529528                });
    530529
     
    532531                {
    533532                    b.Property<int>("Id")
    534                         .ValueGeneratedOnAdd()
    535                         .HasColumnType("integer");
    536 
    537                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     533                        .HasColumnType("integer")
     534                        .HasColumnName("user_id");
    538535
    539536                    b.Property<string>("Bio")
    540                         .IsRequired()
    541                         .HasColumnType("text");
    542 
    543                     b.Property<int>("UserId")
    544                         .HasColumnType("integer");
    545 
    546                     b.HasKey("Id");
    547 
    548                     b.HasIndex("UserId")
    549                         .IsUnique();
    550 
    551                     b.ToTable("Writers");
     537                        .HasColumnType("text")
     538                        .HasColumnName("bio");
     539
     540                    b.HasKey("Id");
     541
     542                    b.ToTable("writer", (string)null);
    552543                });
    553544
     
    567558                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    568559                        .WithOne("Admin")
    569                         .HasForeignKey("ChapterX.Domain.Entities.Admin", "UserId")
     560                        .HasForeignKey("ChapterX.Domain.Entities.Admin", "Id")
    570561                        .OnDelete(DeleteBehavior.Cascade)
    571562                        .IsRequired();
     
    644635            modelBuilder.Entity("ChapterX.Domain.Entities.Likes", b =>
    645636                {
    646                     b.HasOne("ChapterX.Domain.Entities.Chapter", "Chapter")
    647                         .WithMany()
    648                         .HasForeignKey("ChapterId")
    649                         .OnDelete(DeleteBehavior.Cascade)
    650                         .IsRequired();
    651 
    652                     b.HasOne("ChapterX.Domain.Entities.Story", null)
     637                    b.HasOne("ChapterX.Domain.Entities.Story", "Story")
    653638                        .WithMany("Likes")
    654                         .HasForeignKey("StoryId");
     639                        .HasForeignKey("StoryId")
     640                        .OnDelete(DeleteBehavior.Cascade)
     641                        .IsRequired();
    655642
    656643                    b.HasOne("ChapterX.Domain.Entities.User", "User")
     
    660647                        .IsRequired();
    661648
    662                     b.Navigation("Chapter");
     649                    b.Navigation("Story");
    663650
    664651                    b.Navigation("User");
     
    667654            modelBuilder.Entity("ChapterX.Domain.Entities.NeedApproval", b =>
    668655                {
    669                     b.HasOne("ChapterX.Domain.Entities.AISuggestion", null)
     656                    b.HasOne("ChapterX.Domain.Entities.Chapter", "Chapter")
    670657                        .WithMany("NeedApprovals")
    671                         .HasForeignKey("AISuggestionId");
    672 
    673                     b.HasOne("ChapterX.Domain.Entities.Admin", "Admin")
    674                         .WithMany()
    675                         .HasForeignKey("AdminId")
    676                         .OnDelete(DeleteBehavior.Cascade)
    677                         .IsRequired();
    678 
    679                     b.HasOne("ChapterX.Domain.Entities.Chapter", null)
    680                         .WithMany("NeedApprovals")
    681                         .HasForeignKey("ChapterId");
     658                        .HasForeignKey("ChapterId")
     659                        .OnDelete(DeleteBehavior.Cascade)
     660                        .IsRequired();
    682661
    683662                    b.HasOne("ChapterX.Domain.Entities.Story", "Story")
     
    687666                        .IsRequired();
    688667
    689                     b.Navigation("Admin");
     668                    b.HasOne("ChapterX.Domain.Entities.AISuggestion", "AISuggestion")
     669                        .WithMany("NeedApprovals")
     670                        .HasForeignKey("SuggestionId")
     671                        .OnDelete(DeleteBehavior.Cascade)
     672                        .IsRequired();
     673
     674                    b.Navigation("AISuggestion");
     675
     676                    b.Navigation("Chapter");
    690677
    691678                    b.Navigation("Story");
    692679                });
    693680
    694             modelBuilder.Entity("ChapterX.Domain.Entities.Notify", b =>
    695                 {
    696                     b.HasOne("ChapterX.Domain.Entities.Notification", "Notification")
    697                         .WithMany("Notifies")
    698                         .HasForeignKey("NotificationId")
    699                         .OnDelete(DeleteBehavior.Cascade)
    700                         .IsRequired();
    701 
    702                     b.HasOne("ChapterX.Domain.Entities.Story", null)
    703                         .WithMany("Notifies")
    704                         .HasForeignKey("StoryId");
     681            modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
     682                {
     683                    b.HasOne("ChapterX.Domain.Entities.Story", "Story")
     684                        .WithMany("Notifications")
     685                        .HasForeignKey("StoryId")
     686                        .OnDelete(DeleteBehavior.SetNull);
    705687
    706688                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    707                         .WithMany("Notifies")
     689                        .WithMany("Notifications")
    708690                        .HasForeignKey("UserId")
    709691                        .OnDelete(DeleteBehavior.Cascade)
    710692                        .IsRequired();
    711693
    712                     b.Navigation("Notification");
     694                    b.Navigation("Story");
    713695
    714696                    b.Navigation("User");
     
    730712                    b.HasOne("ChapterX.Domain.Entities.ReadingList", "ReadingList")
    731713                        .WithMany("ReadingListItems")
    732                         .HasForeignKey("ReadingListId")
     714                        .HasForeignKey("ListId")
    733715                        .OnDelete(DeleteBehavior.Cascade)
    734716                        .IsRequired();
     
    749731                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    750732                        .WithOne("RegularUser")
    751                         .HasForeignKey("ChapterX.Domain.Entities.RegularUser", "UserId")
     733                        .HasForeignKey("ChapterX.Domain.Entities.RegularUser", "Id")
    752734                        .OnDelete(DeleteBehavior.Cascade)
    753735                        .IsRequired();
     
    760742                    b.HasOne("ChapterX.Domain.Entities.Writer", "Writer")
    761743                        .WithMany("Stories")
    762                         .HasForeignKey("WriterId")
     744                        .HasForeignKey("UserId")
    763745                        .OnDelete(DeleteBehavior.Cascade)
    764746                        .IsRequired();
     
    771753                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    772754                        .WithOne("Writer")
    773                         .HasForeignKey("ChapterX.Domain.Entities.Writer", "UserId")
     755                        .HasForeignKey("ChapterX.Domain.Entities.Writer", "Id")
    774756                        .OnDelete(DeleteBehavior.Cascade)
    775757                        .IsRequired();
     
    793775                });
    794776
    795             modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
    796                 {
    797                     b.Navigation("Notifies");
    798                 });
    799 
    800777            modelBuilder.Entity("ChapterX.Domain.Entities.ReadingList", b =>
    801778                {
     
    819796                    b.Navigation("NeedApprovals");
    820797
    821                     b.Navigation("Notifies");
     798                    b.Navigation("Notifications");
    822799
    823800                    b.Navigation("ReadingListItems");
     
    834811                    b.Navigation("Likes");
    835812
    836                     b.Navigation("Notifies");
     813                    b.Navigation("Notifications");
    837814
    838815                    b.Navigation("ReadingLists");
  • ChapterX.Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs

    ra6e33d1 re882b92  
    2727                    b.Property<int>("Id")
    2828                        .ValueGeneratedOnAdd()
    29                         .HasColumnType("integer");
     29                        .HasColumnType("integer")
     30                        .HasColumnName("suggestion_id");
    3031
    3132                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    3233
    3334                    b.Property<bool?>("Accepted")
    34                         .HasColumnType("boolean");
     35                        .HasColumnType("boolean")
     36                        .HasColumnName("accepted");
    3537
    3638                    b.Property<DateTime?>("AppliedAt")
    37                         .HasColumnType("timestamp with time zone");
     39                        .HasColumnType("timestamp with time zone")
     40                        .HasColumnName("applied_at");
    3841
    3942                    b.Property<DateTime>("CreatedAt")
    40                         .HasColumnType("timestamp with time zone");
     43                        .HasColumnType("timestamp with time zone")
     44                        .HasColumnName("suggestion_created_at");
    4145
    4246                    b.Property<string>("OriginalText")
    4347                        .IsRequired()
    44                         .HasColumnType("text");
     48                        .HasColumnType("text")
     49                        .HasColumnName("original_text");
    4550
    4651                    b.Property<int>("StoryId")
    47                         .HasColumnType("integer");
     52                        .HasColumnType("integer")
     53                        .HasColumnName("story_id");
    4854
    4955                    b.Property<string>("SuggestedText")
    5056                        .IsRequired()
    51                         .HasColumnType("text");
    52 
    53                     b.PrimitiveCollection<int[]>("SuggestionTypes")
    54                         .IsRequired()
    55                         .HasColumnType("integer[]");
     57                        .HasColumnType("text")
     58                        .HasColumnName("suggested_text");
     59
     60                    b.Property<string>("SuggestionType")
     61                        .IsRequired()
     62                        .HasColumnType("text")
     63                        .HasColumnName("suggestion_type");
    5664
    5765                    b.HasKey("Id");
     
    5967                    b.HasIndex("StoryId");
    6068
    61                     b.ToTable("AISuggestions", (string)null);
     69                    b.ToTable("ai_suggestion", (string)null);
    6270                });
    6371
     
    6573                {
    6674                    b.Property<int>("Id")
     75                        .HasColumnType("integer")
     76                        .HasColumnName("user_id");
     77
     78                    b.Property<DateTime>("AssignedAt")
     79                        .HasColumnType("timestamp with time zone")
     80                        .HasColumnName("assigned_at");
     81
     82                    b.HasKey("Id");
     83
     84                    b.ToTable("admins", (string)null);
     85                });
     86
     87            modelBuilder.Entity("ChapterX.Domain.Entities.Chapter", b =>
     88                {
     89                    b.Property<int>("Id")
    6790                        .ValueGeneratedOnAdd()
    68                         .HasColumnType("integer");
     91                        .HasColumnType("integer")
     92                        .HasColumnName("chapter_id");
    6993
    7094                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    7195
     96                    b.Property<string>("Content")
     97                        .IsRequired()
     98                        .HasColumnType("text")
     99                        .HasColumnName("chapter_content");
     100
     101                    b.Property<DateTime>("CreatedAt")
     102                        .HasColumnType("timestamp with time zone")
     103                        .HasColumnName("chapter_created_at");
     104
     105                    b.Property<string>("Name")
     106                        .IsRequired()
     107                        .HasColumnType("text")
     108                        .HasColumnName("chapter_name");
     109
     110                    b.Property<int>("Number")
     111                        .HasColumnType("integer")
     112                        .HasColumnName("chapter_number");
     113
     114                    b.Property<DateTime>("PublishedAt")
     115                        .HasColumnType("timestamp with time zone")
     116                        .HasColumnName("published_at");
     117
     118                    b.Property<decimal?>("Rating")
     119                        .HasColumnType("numeric")
     120                        .HasColumnName("rating");
     121
     122                    b.Property<int>("StoryId")
     123                        .HasColumnType("integer")
     124                        .HasColumnName("story_id");
     125
     126                    b.Property<string>("Title")
     127                        .IsRequired()
     128                        .HasColumnType("text")
     129                        .HasColumnName("title");
     130
     131                    b.Property<DateTime>("UpdatedAt")
     132                        .HasColumnType("timestamp with time zone")
     133                        .HasColumnName("chapter_updated_at");
     134
     135                    b.Property<int>("ViewCount")
     136                        .HasColumnType("integer")
     137                        .HasColumnName("view_count");
     138
     139                    b.Property<int?>("WordCount")
     140                        .HasColumnType("integer")
     141                        .HasColumnName("word_count");
     142
     143                    b.HasKey("Id");
     144
     145                    b.HasIndex("StoryId");
     146
     147                    b.ToTable("chapter", (string)null);
     148                });
     149
     150            modelBuilder.Entity("ChapterX.Domain.Entities.Collaboration", b =>
     151                {
    72152                    b.Property<int>("UserId")
    73                         .HasColumnType("integer");
    74 
    75                     b.HasKey("Id");
    76 
    77                     b.HasIndex("UserId")
    78                         .IsUnique();
    79 
    80                     b.ToTable("Admins", (string)null);
    81                 });
    82 
    83             modelBuilder.Entity("ChapterX.Domain.Entities.Chapter", b =>
     153                        .HasColumnType("integer")
     154                        .HasColumnName("user_id");
     155
     156                    b.Property<int>("StoryId")
     157                        .HasColumnType("integer")
     158                        .HasColumnName("story_id");
     159
     160                    b.Property<DateTime>("CreatedAt")
     161                        .HasColumnType("timestamp with time zone")
     162                        .HasColumnName("collab_created_at");
     163
     164                    b.Property<int?>("PermissionLevel")
     165                        .HasColumnType("integer")
     166                        .HasColumnName("permission_level");
     167
     168                    b.Property<string>("Role")
     169                        .IsRequired()
     170                        .HasColumnType("text")
     171                        .HasColumnName("role");
     172
     173                    b.HasKey("UserId", "StoryId");
     174
     175                    b.HasIndex("StoryId");
     176
     177                    b.ToTable("collaboration", (string)null);
     178                });
     179
     180            modelBuilder.Entity("ChapterX.Domain.Entities.Comment", b =>
    84181                {
    85182                    b.Property<int>("Id")
    86183                        .ValueGeneratedOnAdd()
    87                         .HasColumnType("integer");
     184                        .HasColumnType("integer")
     185                        .HasColumnName("comment_id");
    88186
    89187                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     
    91189                    b.Property<string>("Content")
    92190                        .IsRequired()
    93                         .HasColumnType("text");
     191                        .HasColumnType("text")
     192                        .HasColumnName("comment_content");
    94193
    95194                    b.Property<DateTime>("CreatedAt")
    96                         .HasColumnType("timestamp with time zone");
     195                        .HasColumnType("timestamp with time zone")
     196                        .HasColumnName("comment_created_at");
     197
     198                    b.Property<int>("StoryId")
     199                        .HasColumnType("integer")
     200                        .HasColumnName("story_id");
     201
     202                    b.Property<DateTime>("UpdatedAt")
     203                        .HasColumnType("timestamp with time zone")
     204                        .HasColumnName("comment_updated_at");
     205
     206                    b.Property<int>("UserId")
     207                        .HasColumnType("integer")
     208                        .HasColumnName("user_id");
     209
     210                    b.HasKey("Id");
     211
     212                    b.HasIndex("StoryId");
     213
     214                    b.HasIndex("UserId");
     215
     216                    b.ToTable("comment", (string)null);
     217                });
     218
     219            modelBuilder.Entity("ChapterX.Domain.Entities.Genre", b =>
     220                {
     221                    b.Property<int>("Id")
     222                        .ValueGeneratedOnAdd()
     223                        .HasColumnType("integer")
     224                        .HasColumnName("genre_id");
     225
     226                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    97227
    98228                    b.Property<string>("Name")
    99229                        .IsRequired()
    100                         .HasColumnType("text");
    101 
    102                     b.Property<int>("Number")
    103                         .HasColumnType("integer");
    104 
    105                     b.Property<DateTime>("PublishedAt")
    106                         .HasColumnType("timestamp with time zone");
    107 
    108                     b.Property<decimal?>("Rating")
    109                         .HasColumnType("numeric");
    110 
     230                        .HasColumnType("text")
     231                        .HasColumnName("genre_name");
     232
     233                    b.HasKey("Id");
     234
     235                    b.ToTable("genre", (string)null);
     236                });
     237
     238            modelBuilder.Entity("ChapterX.Domain.Entities.HasGenre", b =>
     239                {
    111240                    b.Property<int>("StoryId")
    112                         .HasColumnType("integer");
     241                        .HasColumnType("integer")
     242                        .HasColumnName("story_id");
     243
     244                    b.Property<int>("GenreId")
     245                        .HasColumnType("integer")
     246                        .HasColumnName("genre_id");
     247
     248                    b.HasKey("StoryId", "GenreId");
     249
     250                    b.HasIndex("GenreId");
     251
     252                    b.ToTable("has_genre", (string)null);
     253                });
     254
     255            modelBuilder.Entity("ChapterX.Domain.Entities.Likes", b =>
     256                {
     257                    b.Property<int>("UserId")
     258                        .HasColumnType("integer")
     259                        .HasColumnName("user_id");
     260
     261                    b.Property<int>("StoryId")
     262                        .HasColumnType("integer")
     263                        .HasColumnName("story_id");
     264
     265                    b.Property<DateTime>("LikedAt")
     266                        .HasColumnType("timestamp with time zone")
     267                        .HasColumnName("liked_at");
     268
     269                    b.HasKey("UserId", "StoryId");
     270
     271                    b.HasIndex("StoryId");
     272
     273                    b.ToTable("likes", (string)null);
     274                });
     275
     276            modelBuilder.Entity("ChapterX.Domain.Entities.NeedApproval", b =>
     277                {
     278                    b.Property<int>("SuggestionId")
     279                        .HasColumnType("integer")
     280                        .HasColumnName("suggestion_id");
     281
     282                    b.Property<int>("StoryId")
     283                        .HasColumnType("integer")
     284                        .HasColumnName("story_id");
     285
     286                    b.Property<int>("ChapterId")
     287                        .HasColumnType("integer")
     288                        .HasColumnName("chapter_id");
     289
     290                    b.HasKey("SuggestionId", "StoryId", "ChapterId");
     291
     292                    b.HasIndex("ChapterId");
     293
     294                    b.HasIndex("StoryId");
     295
     296                    b.ToTable("need_approval", (string)null);
     297                });
     298
     299            modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
     300                {
     301                    b.Property<int>("Id")
     302                        .ValueGeneratedOnAdd()
     303                        .HasColumnType("integer")
     304                        .HasColumnName("notification_id");
     305
     306                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     307
     308                    b.Property<string>("Content")
     309                        .IsRequired()
     310                        .HasColumnType("text")
     311                        .HasColumnName("notification_content");
     312
     313                    b.Property<string>("ContentType")
     314                        .IsRequired()
     315                        .HasColumnType("text")
     316                        .HasColumnName("content_type");
     317
     318                    b.Property<DateTime>("CreatedAt")
     319                        .HasColumnType("timestamp with time zone")
     320                        .HasColumnName("notification_created_at");
     321
     322                    b.Property<bool>("IsRead")
     323                        .HasColumnType("boolean")
     324                        .HasColumnName("is_read");
     325
     326                    b.Property<string>("Link")
     327                        .HasColumnType("text")
     328                        .HasColumnName("link");
     329
     330                    b.Property<int?>("StoryId")
     331                        .HasColumnType("integer")
     332                        .HasColumnName("story_id");
     333
     334                    b.Property<int>("UserId")
     335                        .HasColumnType("integer")
     336                        .HasColumnName("user_id");
     337
     338                    b.HasKey("Id");
     339
     340                    b.HasIndex("StoryId");
     341
     342                    b.HasIndex("UserId");
     343
     344                    b.ToTable("notification", (string)null);
     345                });
     346
     347            modelBuilder.Entity("ChapterX.Domain.Entities.ReadingList", b =>
     348                {
     349                    b.Property<int>("Id")
     350                        .ValueGeneratedOnAdd()
     351                        .HasColumnType("integer")
     352                        .HasColumnName("list_id");
     353
     354                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     355
     356                    b.Property<string>("Content")
     357                        .HasColumnType("text")
     358                        .HasColumnName("list_content");
     359
     360                    b.Property<DateTime>("CreatedAt")
     361                        .HasColumnType("timestamp with time zone")
     362                        .HasColumnName("list_created_at");
     363
     364                    b.Property<bool>("IsPublic")
     365                        .HasColumnType("boolean")
     366                        .HasColumnName("is_public");
     367
     368                    b.Property<string>("Name")
     369                        .IsRequired()
     370                        .HasColumnType("text")
     371                        .HasColumnName("list_name");
     372
     373                    b.Property<DateTime>("UpdatedAt")
     374                        .HasColumnType("timestamp with time zone")
     375                        .HasColumnName("list_updated_at");
     376
     377                    b.Property<int>("UserId")
     378                        .HasColumnType("integer")
     379                        .HasColumnName("user_id");
     380
     381                    b.HasKey("Id");
     382
     383                    b.HasIndex("UserId");
     384
     385                    b.ToTable("reading_list", (string)null);
     386                });
     387
     388            modelBuilder.Entity("ChapterX.Domain.Entities.ReadingListItems", b =>
     389                {
     390                    b.Property<int>("ListId")
     391                        .HasColumnType("integer")
     392                        .HasColumnName("list_id");
     393
     394                    b.Property<int>("StoryId")
     395                        .HasColumnType("integer")
     396                        .HasColumnName("story_id");
     397
     398                    b.Property<DateTime>("AddedAt")
     399                        .HasColumnType("timestamp with time zone")
     400                        .HasColumnName("added_at");
     401
     402                    b.HasKey("ListId", "StoryId");
     403
     404                    b.HasIndex("StoryId");
     405
     406                    b.ToTable("reading_list_items", (string)null);
     407                });
     408
     409            modelBuilder.Entity("ChapterX.Domain.Entities.RegularUser", b =>
     410                {
     411                    b.Property<int>("Id")
     412                        .HasColumnType("integer")
     413                        .HasColumnName("user_id");
     414
     415                    b.Property<DateTime>("JoinedAt")
     416                        .HasColumnType("timestamp with time zone")
     417                        .HasColumnName("joined_at");
     418
     419                    b.HasKey("Id");
     420
     421                    b.ToTable("regular_user", (string)null);
     422                });
     423
     424            modelBuilder.Entity("ChapterX.Domain.Entities.Story", b =>
     425                {
     426                    b.Property<int>("Id")
     427                        .ValueGeneratedOnAdd()
     428                        .HasColumnType("integer")
     429                        .HasColumnName("story_id");
     430
     431                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     432
     433                    b.Property<string>("Content")
     434                        .IsRequired()
     435                        .HasColumnType("text")
     436                        .HasColumnName("story_content");
     437
     438                    b.Property<DateTime>("CreatedAt")
     439                        .HasColumnType("timestamp with time zone")
     440                        .HasColumnName("story_created_at");
     441
     442                    b.Property<string>("Image")
     443                        .HasColumnType("text")
     444                        .HasColumnName("image");
     445
     446                    b.Property<bool>("MatureContent")
     447                        .HasColumnType("boolean")
     448                        .HasColumnName("mature_content");
     449
     450                    b.Property<string>("ShortDescription")
     451                        .IsRequired()
     452                        .HasColumnType("text")
     453                        .HasColumnName("short_description");
     454
     455                    b.Property<string>("Status")
     456                        .IsRequired()
     457                        .HasColumnType("text")
     458                        .HasColumnName("status");
    113459
    114460                    b.Property<string>("Title")
    115461                        .IsRequired()
    116                         .HasColumnType("text");
     462                        .HasColumnType("text")
     463                        .HasColumnName("title");
    117464
    118465                    b.Property<DateTime>("UpdatedAt")
    119                         .HasColumnType("timestamp with time zone");
    120 
    121                     b.Property<int>("ViewCount")
    122                         .HasColumnType("integer");
    123 
    124                     b.Property<int?>("WordCount")
    125                         .HasColumnType("integer");
    126 
    127                     b.HasKey("Id");
    128 
    129                     b.HasIndex("StoryId");
    130 
    131                     b.ToTable("Chapters", (string)null);
    132                 });
    133 
    134             modelBuilder.Entity("ChapterX.Domain.Entities.Collaboration", b =>
     466                        .HasColumnType("timestamp with time zone")
     467                        .HasColumnName("story_updated_at");
     468
     469                    b.Property<int>("UserId")
     470                        .HasColumnType("integer")
     471                        .HasColumnName("user_id");
     472
     473                    b.HasKey("Id");
     474
     475                    b.HasIndex("UserId");
     476
     477                    b.ToTable("story", (string)null);
     478                });
     479
     480            modelBuilder.Entity("ChapterX.Domain.Entities.User", b =>
    135481                {
    136482                    b.Property<int>("Id")
    137483                        .ValueGeneratedOnAdd()
    138                         .HasColumnType("integer");
     484                        .HasColumnType("integer")
     485                        .HasColumnName("user_id");
    139486
    140487                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    141488
    142                     b.Property<DateTime>("JoinedAt")
    143                         .HasColumnType("timestamp with time zone");
    144 
    145                     b.Property<string>("Role")
    146                         .IsRequired()
    147                         .HasColumnType("text");
    148 
    149                     b.Property<int>("StoryId")
    150                         .HasColumnType("integer");
    151 
    152                     b.Property<int>("UserId")
    153                         .HasColumnType("integer");
    154 
    155                     b.HasKey("Id");
    156 
    157                     b.HasIndex("StoryId");
    158 
    159                     b.HasIndex("UserId");
    160 
    161                     b.ToTable("Collaborations", (string)null);
    162                 });
    163 
    164             modelBuilder.Entity("ChapterX.Domain.Entities.Comment", b =>
    165                 {
    166                     b.Property<int>("Id")
    167                         .ValueGeneratedOnAdd()
    168                         .HasColumnType("integer");
    169 
    170                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    171 
    172                     b.Property<string>("Content")
    173                         .IsRequired()
    174                         .HasColumnType("text");
    175 
    176489                    b.Property<DateTime>("CreatedAt")
    177                         .HasColumnType("timestamp with time zone");
    178 
    179                     b.Property<int>("StoryId")
    180                         .HasColumnType("integer");
     490                        .HasColumnType("timestamp with time zone")
     491                        .HasColumnName("user_created_at");
     492
     493                    b.Property<string>("Email")
     494                        .IsRequired()
     495                        .HasColumnType("text")
     496                        .HasColumnName("email");
     497
     498                    b.Property<string>("Name")
     499                        .IsRequired()
     500                        .HasColumnType("text")
     501                        .HasColumnName("user_name");
     502
     503                    b.Property<string>("Password")
     504                        .IsRequired()
     505                        .HasColumnType("text")
     506                        .HasColumnName("password");
     507
     508                    b.Property<string>("Surname")
     509                        .IsRequired()
     510                        .HasColumnType("text")
     511                        .HasColumnName("surname");
    181512
    182513                    b.Property<DateTime>("UpdatedAt")
    183                         .HasColumnType("timestamp with time zone");
    184 
    185                     b.Property<int>("UserId")
    186                         .HasColumnType("integer");
    187 
    188                     b.HasKey("Id");
    189 
    190                     b.HasIndex("StoryId");
    191 
    192                     b.HasIndex("UserId");
    193 
    194                     b.ToTable("Comments", (string)null);
    195                 });
    196 
    197             modelBuilder.Entity("ChapterX.Domain.Entities.Genre", b =>
    198                 {
    199                     b.Property<int>("Id")
    200                         .ValueGeneratedOnAdd()
    201                         .HasColumnType("integer");
    202 
    203                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    204 
    205                     b.Property<string>("Name")
    206                         .IsRequired()
    207                         .HasColumnType("text");
    208 
    209                     b.HasKey("Id");
    210 
    211                     b.ToTable("Genres", (string)null);
    212                 });
    213 
    214             modelBuilder.Entity("ChapterX.Domain.Entities.HasGenre", b =>
    215                 {
    216                     b.Property<int>("Id")
    217                         .ValueGeneratedOnAdd()
    218                         .HasColumnType("integer");
    219 
    220                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    221 
    222                     b.Property<int>("GenreId")
    223                         .HasColumnType("integer");
    224 
    225                     b.Property<int>("StoryId")
    226                         .HasColumnType("integer");
    227 
    228                     b.HasKey("Id");
    229 
    230                     b.HasIndex("GenreId");
    231 
    232                     b.HasIndex("StoryId");
    233 
    234                     b.ToTable("HasGenres", (string)null);
    235                 });
    236 
    237             modelBuilder.Entity("ChapterX.Domain.Entities.Likes", b =>
    238                 {
    239                     b.Property<int>("Id")
    240                         .ValueGeneratedOnAdd()
    241                         .HasColumnType("integer");
    242 
    243                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    244 
    245                     b.Property<int>("ChapterId")
    246                         .HasColumnType("integer");
    247 
    248                     b.Property<DateTime>("CreatedAt")
    249                         .HasColumnType("timestamp with time zone");
    250 
    251                     b.Property<int?>("StoryId")
    252                         .HasColumnType("integer");
    253 
    254                     b.Property<int>("UserId")
    255                         .HasColumnType("integer");
    256 
    257                     b.HasKey("Id");
    258 
    259                     b.HasIndex("ChapterId");
    260 
    261                     b.HasIndex("StoryId");
    262 
    263                     b.HasIndex("UserId");
    264 
    265                     b.ToTable("Likes", (string)null);
    266                 });
    267 
    268             modelBuilder.Entity("ChapterX.Domain.Entities.NeedApproval", b =>
    269                 {
    270                     b.Property<int>("Id")
    271                         .ValueGeneratedOnAdd()
    272                         .HasColumnType("integer");
    273 
    274                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    275 
    276                     b.Property<int?>("AISuggestionId")
    277                         .HasColumnType("integer");
    278 
    279                     b.Property<int>("AdminId")
    280                         .HasColumnType("integer");
    281 
    282                     b.Property<bool>("Approved")
    283                         .HasColumnType("boolean");
    284 
    285                     b.Property<int?>("ChapterId")
    286                         .HasColumnType("integer");
    287 
    288                     b.Property<DateTime>("RequestedAt")
    289                         .HasColumnType("timestamp with time zone");
    290 
    291                     b.Property<int>("StoryId")
    292                         .HasColumnType("integer");
    293 
    294                     b.HasKey("Id");
    295 
    296                     b.HasIndex("AISuggestionId");
    297 
    298                     b.HasIndex("AdminId");
    299 
    300                     b.HasIndex("ChapterId");
    301 
    302                     b.HasIndex("StoryId");
    303 
    304                     b.ToTable("NeedApprovals", (string)null);
    305                 });
    306 
    307             modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
    308                 {
    309                     b.Property<int>("Id")
    310                         .ValueGeneratedOnAdd()
    311                         .HasColumnType("integer");
    312 
    313                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    314 
    315                     b.Property<string>("Content")
    316                         .IsRequired()
    317                         .HasColumnType("text");
    318 
    319                     b.PrimitiveCollection<int[]>("ContentTypes")
    320                         .IsRequired()
    321                         .HasColumnType("integer[]");
    322 
    323                     b.Property<DateTime>("CreatedAt")
    324                         .HasColumnType("timestamp with time zone");
    325 
    326                     b.Property<bool>("IsRead")
    327                         .HasColumnType("boolean");
    328 
    329                     b.HasKey("Id");
    330 
    331                     b.ToTable("Notifications", (string)null);
    332                 });
    333 
    334             modelBuilder.Entity("ChapterX.Domain.Entities.Notify", b =>
    335                 {
    336                     b.Property<int>("Id")
    337                         .ValueGeneratedOnAdd()
    338                         .HasColumnType("integer");
    339 
    340                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    341 
    342                     b.Property<bool>("IsRead")
    343                         .HasColumnType("boolean");
    344 
    345                     b.Property<int>("NotificationId")
    346                         .HasColumnType("integer");
    347 
    348                     b.Property<int?>("StoryId")
    349                         .HasColumnType("integer");
    350 
    351                     b.Property<int>("UserId")
    352                         .HasColumnType("integer");
    353 
    354                     b.HasKey("Id");
    355 
    356                     b.HasIndex("NotificationId");
    357 
    358                     b.HasIndex("StoryId");
    359 
    360                     b.HasIndex("UserId");
    361 
    362                     b.ToTable("Notifies", (string)null);
    363                 });
    364 
    365             modelBuilder.Entity("ChapterX.Domain.Entities.ReadingList", b =>
    366                 {
    367                     b.Property<int>("Id")
    368                         .ValueGeneratedOnAdd()
    369                         .HasColumnType("integer");
    370 
    371                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    372 
    373                     b.Property<string>("Content")
    374                         .HasColumnType("text");
    375 
    376                     b.Property<DateTime>("CreatedAt")
    377                         .HasColumnType("timestamp with time zone");
    378 
    379                     b.Property<bool>("IsPublic")
    380                         .HasColumnType("boolean");
    381 
    382                     b.Property<string>("Name")
    383                         .IsRequired()
    384                         .HasColumnType("text");
    385 
    386                     b.Property<DateTime>("UpdatedAt")
    387                         .HasColumnType("timestamp with time zone");
    388 
    389                     b.Property<int>("UserId")
    390                         .HasColumnType("integer");
    391 
    392                     b.HasKey("Id");
    393 
    394                     b.HasIndex("UserId");
    395 
    396                     b.ToTable("ReadingLists", (string)null);
    397                 });
    398 
    399             modelBuilder.Entity("ChapterX.Domain.Entities.ReadingListItems", b =>
    400                 {
    401                     b.Property<int>("Id")
    402                         .ValueGeneratedOnAdd()
    403                         .HasColumnType("integer");
    404 
    405                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    406 
    407                     b.Property<DateTime>("AddedAt")
    408                         .HasColumnType("timestamp with time zone");
    409 
    410                     b.Property<int>("ReadingListId")
    411                         .HasColumnType("integer");
    412 
    413                     b.Property<int>("StoryId")
    414                         .HasColumnType("integer");
    415 
    416                     b.HasKey("Id");
    417 
    418                     b.HasIndex("ReadingListId");
    419 
    420                     b.HasIndex("StoryId");
    421 
    422                     b.ToTable("ReadingListItems", (string)null);
    423                 });
    424 
    425             modelBuilder.Entity("ChapterX.Domain.Entities.RegularUser", b =>
    426                 {
    427                     b.Property<int>("Id")
    428                         .ValueGeneratedOnAdd()
    429                         .HasColumnType("integer");
    430 
    431                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    432 
    433                     b.Property<int>("UserId")
    434                         .HasColumnType("integer");
    435 
    436                     b.HasKey("Id");
    437 
    438                     b.HasIndex("UserId")
    439                         .IsUnique();
    440 
    441                     b.ToTable("RegularUsers", (string)null);
    442                 });
    443 
    444             modelBuilder.Entity("ChapterX.Domain.Entities.Story", b =>
    445                 {
    446                     b.Property<int>("Id")
    447                         .ValueGeneratedOnAdd()
    448                         .HasColumnType("integer");
    449 
    450                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    451 
    452                     b.Property<string>("Content")
    453                         .IsRequired()
    454                         .HasColumnType("text");
    455 
    456                     b.Property<DateTime>("CreatedAt")
    457                         .HasColumnType("timestamp with time zone");
    458 
    459                     b.Property<string>("Image")
    460                         .HasColumnType("text");
    461 
    462                     b.Property<bool>("MatureContent")
    463                         .HasColumnType("boolean");
    464 
    465                     b.Property<string>("ShortDescription")
    466                         .IsRequired()
    467                         .HasColumnType("text");
    468 
    469                     b.PrimitiveCollection<int[]>("Statuses")
    470                         .IsRequired()
    471                         .HasColumnType("integer[]");
    472 
    473                     b.Property<DateTime>("UpdatedAt")
    474                         .HasColumnType("timestamp with time zone");
    475 
    476                     b.Property<int>("UserId")
    477                         .HasColumnType("integer");
    478 
    479                     b.Property<int>("WriterId")
    480                         .HasColumnType("integer");
    481 
    482                     b.HasKey("Id");
    483 
    484                     b.HasIndex("WriterId");
    485 
    486                     b.ToTable("Stories", (string)null);
    487                 });
    488 
    489             modelBuilder.Entity("ChapterX.Domain.Entities.User", b =>
    490                 {
    491                     b.Property<int>("Id")
    492                         .ValueGeneratedOnAdd()
    493                         .HasColumnType("integer");
    494 
    495                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
    496 
    497                     b.Property<DateTime>("CreatedAt")
    498                         .HasColumnType("timestamp with time zone");
    499 
    500                     b.Property<string>("Email")
    501                         .IsRequired()
    502                         .HasColumnType("text");
    503 
    504                     b.Property<string>("Name")
    505                         .IsRequired()
    506                         .HasColumnType("text");
    507 
    508                     b.Property<string>("Password")
    509                         .IsRequired()
    510                         .HasColumnType("text");
    511 
    512                     b.Property<string>("Surname")
    513                         .IsRequired()
    514                         .HasColumnType("text");
    515 
    516                     b.Property<DateTime>("UpdatedAt")
    517                         .HasColumnType("timestamp with time zone");
     514                        .HasColumnType("timestamp with time zone")
     515                        .HasColumnName("user_updated_at");
    518516
    519517                    b.Property<string>("Username")
    520518                        .IsRequired()
    521                         .HasColumnType("text");
    522 
    523                     b.HasKey("Id");
    524 
    525                     b.ToTable("Users", (string)null);
     519                        .HasColumnType("text")
     520                        .HasColumnName("username");
     521
     522                    b.HasKey("Id");
     523
     524                    b.ToTable("users", (string)null);
    526525                });
    527526
     
    529528                {
    530529                    b.Property<int>("Id")
    531                         .ValueGeneratedOnAdd()
    532                         .HasColumnType("integer");
    533 
    534                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
     530                        .HasColumnType("integer")
     531                        .HasColumnName("user_id");
    535532
    536533                    b.Property<string>("Bio")
    537                         .IsRequired()
    538                         .HasColumnType("text");
    539 
    540                     b.Property<int>("UserId")
    541                         .HasColumnType("integer");
    542 
    543                     b.HasKey("Id");
    544 
    545                     b.HasIndex("UserId")
    546                         .IsUnique();
    547 
    548                     b.ToTable("Writers", (string)null);
     534                        .HasColumnType("text")
     535                        .HasColumnName("bio");
     536
     537                    b.HasKey("Id");
     538
     539                    b.ToTable("writer", (string)null);
    549540                });
    550541
     
    564555                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    565556                        .WithOne("Admin")
    566                         .HasForeignKey("ChapterX.Domain.Entities.Admin", "UserId")
     557                        .HasForeignKey("ChapterX.Domain.Entities.Admin", "Id")
    567558                        .OnDelete(DeleteBehavior.Cascade)
    568559                        .IsRequired();
     
    641632            modelBuilder.Entity("ChapterX.Domain.Entities.Likes", b =>
    642633                {
    643                     b.HasOne("ChapterX.Domain.Entities.Chapter", "Chapter")
    644                         .WithMany()
    645                         .HasForeignKey("ChapterId")
    646                         .OnDelete(DeleteBehavior.Cascade)
    647                         .IsRequired();
    648 
    649                     b.HasOne("ChapterX.Domain.Entities.Story", null)
     634                    b.HasOne("ChapterX.Domain.Entities.Story", "Story")
    650635                        .WithMany("Likes")
    651                         .HasForeignKey("StoryId");
     636                        .HasForeignKey("StoryId")
     637                        .OnDelete(DeleteBehavior.Cascade)
     638                        .IsRequired();
    652639
    653640                    b.HasOne("ChapterX.Domain.Entities.User", "User")
     
    657644                        .IsRequired();
    658645
    659                     b.Navigation("Chapter");
     646                    b.Navigation("Story");
    660647
    661648                    b.Navigation("User");
     
    664651            modelBuilder.Entity("ChapterX.Domain.Entities.NeedApproval", b =>
    665652                {
    666                     b.HasOne("ChapterX.Domain.Entities.AISuggestion", null)
     653                    b.HasOne("ChapterX.Domain.Entities.Chapter", "Chapter")
    667654                        .WithMany("NeedApprovals")
    668                         .HasForeignKey("AISuggestionId");
    669 
    670                     b.HasOne("ChapterX.Domain.Entities.Admin", "Admin")
    671                         .WithMany()
    672                         .HasForeignKey("AdminId")
    673                         .OnDelete(DeleteBehavior.Cascade)
    674                         .IsRequired();
    675 
    676                     b.HasOne("ChapterX.Domain.Entities.Chapter", null)
    677                         .WithMany("NeedApprovals")
    678                         .HasForeignKey("ChapterId");
     655                        .HasForeignKey("ChapterId")
     656                        .OnDelete(DeleteBehavior.Cascade)
     657                        .IsRequired();
    679658
    680659                    b.HasOne("ChapterX.Domain.Entities.Story", "Story")
     
    684663                        .IsRequired();
    685664
    686                     b.Navigation("Admin");
     665                    b.HasOne("ChapterX.Domain.Entities.AISuggestion", "AISuggestion")
     666                        .WithMany("NeedApprovals")
     667                        .HasForeignKey("SuggestionId")
     668                        .OnDelete(DeleteBehavior.Cascade)
     669                        .IsRequired();
     670
     671                    b.Navigation("AISuggestion");
     672
     673                    b.Navigation("Chapter");
    687674
    688675                    b.Navigation("Story");
    689676                });
    690677
    691             modelBuilder.Entity("ChapterX.Domain.Entities.Notify", b =>
    692                 {
    693                     b.HasOne("ChapterX.Domain.Entities.Notification", "Notification")
    694                         .WithMany("Notifies")
    695                         .HasForeignKey("NotificationId")
    696                         .OnDelete(DeleteBehavior.Cascade)
    697                         .IsRequired();
    698 
    699                     b.HasOne("ChapterX.Domain.Entities.Story", null)
    700                         .WithMany("Notifies")
    701                         .HasForeignKey("StoryId");
     678            modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
     679                {
     680                    b.HasOne("ChapterX.Domain.Entities.Story", "Story")
     681                        .WithMany("Notifications")
     682                        .HasForeignKey("StoryId")
     683                        .OnDelete(DeleteBehavior.SetNull);
    702684
    703685                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    704                         .WithMany("Notifies")
     686                        .WithMany("Notifications")
    705687                        .HasForeignKey("UserId")
    706688                        .OnDelete(DeleteBehavior.Cascade)
    707689                        .IsRequired();
    708690
    709                     b.Navigation("Notification");
     691                    b.Navigation("Story");
    710692
    711693                    b.Navigation("User");
     
    727709                    b.HasOne("ChapterX.Domain.Entities.ReadingList", "ReadingList")
    728710                        .WithMany("ReadingListItems")
    729                         .HasForeignKey("ReadingListId")
     711                        .HasForeignKey("ListId")
    730712                        .OnDelete(DeleteBehavior.Cascade)
    731713                        .IsRequired();
     
    746728                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    747729                        .WithOne("RegularUser")
    748                         .HasForeignKey("ChapterX.Domain.Entities.RegularUser", "UserId")
     730                        .HasForeignKey("ChapterX.Domain.Entities.RegularUser", "Id")
    749731                        .OnDelete(DeleteBehavior.Cascade)
    750732                        .IsRequired();
     
    757739                    b.HasOne("ChapterX.Domain.Entities.Writer", "Writer")
    758740                        .WithMany("Stories")
    759                         .HasForeignKey("WriterId")
     741                        .HasForeignKey("UserId")
    760742                        .OnDelete(DeleteBehavior.Cascade)
    761743                        .IsRequired();
     
    768750                    b.HasOne("ChapterX.Domain.Entities.User", "User")
    769751                        .WithOne("Writer")
    770                         .HasForeignKey("ChapterX.Domain.Entities.Writer", "UserId")
     752                        .HasForeignKey("ChapterX.Domain.Entities.Writer", "Id")
    771753                        .OnDelete(DeleteBehavior.Cascade)
    772754                        .IsRequired();
     
    790772                });
    791773
    792             modelBuilder.Entity("ChapterX.Domain.Entities.Notification", b =>
    793                 {
    794                     b.Navigation("Notifies");
    795                 });
    796 
    797774            modelBuilder.Entity("ChapterX.Domain.Entities.ReadingList", b =>
    798775                {
     
    816793                    b.Navigation("NeedApprovals");
    817794
    818                     b.Navigation("Notifies");
     795                    b.Navigation("Notifications");
    819796
    820797                    b.Navigation("ReadingListItems");
     
    831808                    b.Navigation("Likes");
    832809
    833                     b.Navigation("Notifies");
     810                    b.Navigation("Notifications");
    834811
    835812                    b.Navigation("ReadingLists");
  • ChapterX.Infrastructure/Repositories/AISuggestionRepository.cs

    ra6e33d1 re882b92  
    2121        {
    2222            return await _dbSet
    23                 .Include(a => a.SuggestionTypes)
    2423                .Where(a => a.NeedApprovals.Any(na => na.ChapterId == chapterId))
    2524                .ToListAsync(cancellationToken);
  • ChapterX.Infrastructure/Repositories/NotificationRepository.cs

    ra6e33d1 re882b92  
    1212        }
    1313
    14         // Currently Notification is not linked directly to a User entity.
    15         // This method returns all notifications; adjust filter when a User relation is added.
    1614        public async Task<IEnumerable<Notification>> GetByUserIdAsync(int userId, CancellationToken cancellationToken = default)
    1715            => await _dbSet
    18                 .Where(n => n.RecipientUserId == userId)
     16                .Where(n => n.UserId == userId)
    1917                .OrderByDescending(n => n.CreatedAt)
    2018                .ToListAsync(cancellationToken);
  • chapterx-frontend/src/components/admin/ContentModerationTable.tsx

    ra6e33d1 re882b92  
    2020    deleteStory(story.story_id)
    2121    addNotification({
    22       user_id: story.user_id,
    23       type: 'system',
    24       title: 'Story Removed',
    25       message: `Your story "${story.title}" has been removed by an administrator.`,
     22      userId: story.user_id,
     23      contentType: 'system',
     24      content: `Your story "${story.title}" has been removed by an administrator.`,
    2625    })
    2726    addToast(`"${story.title}" removed from platform`, 'info')
  • chapterx-frontend/src/components/story/CommentSection.tsx

    ra6e33d1 re882b92  
    8080      if (currentUser.user_id !== authorUserId) {
    8181        await addNotification({
    82           recipientUserId: authorUserId,
    83           type: 'comment',
     82          userId: authorUserId,
     83          contentType: 'comment',
    8484          content: `${currentUser.username} commented: "${text.trim().slice(0, 60)}${text.length > 60 ? '...' : ''}"`,
     85          storyId,
    8586          link: `/story/${storyId}`,
    8687        })
  • chapterx-frontend/src/components/story/LikeButton.tsx

    ra6e33d1 re882b92  
    5959        if (currentUser.user_id !== authorUserId) {
    6060          await addNotification({
    61             recipientUserId: authorUserId,
    62             type: 'like',
     61            userId: authorUserId,
     62            contentType: 'like',
    6363            content: `${currentUser.username} liked your story.`,
     64            storyId,
    6465            link: `/story/${storyId}`,
    6566          })
  • chapterx-frontend/src/components/writer/CollaboratorManager.tsx

    ra6e33d1 re882b92  
    6262    addCollaboration(newCollab)
    6363    addNotification({
    64       recipientUserId: user.user_id,
    65       type: 'collaboration',
     64      userId: user.user_id,
     65      contentType: 'collaboration',
    6666      content: `You've been invited to collaborate on "${storyTitle}" as ${selectedRole}.`,
     67      storyId,
    6768      link: `/story/${storyId}`,
    6869    })
  • chapterx-frontend/src/store/notificationStore.ts

    ra6e33d1 re882b92  
    1717  notifications: Notification[]
    1818  fetchUserNotifications: (userId: number) => Promise<void>
    19   addNotification: (n: { recipientUserId: number; type: string; content: string; link?: string }) => Promise<void>
     19  addNotification: (n: { userId: number; contentType: string; content: string; storyId?: number; link?: string }) => Promise<void>
    2020  markAllRead: () => Promise<void>
    2121  markRead: (id: number) => Promise<void>
     
    3333        notification_id: n.id,
    3434        user_id: userId,
    35         type: n.type ?? 'info',
    36         title: n.type ?? 'Notification',
     35        type: n.contentType ?? 'info',
     36        title: n.contentType ?? 'Notification',
    3737        message: n.content,
    3838        link: n.link,
     
    4646  },
    4747
    48   addNotification: async ({ recipientUserId, type, content, link }) => {
     48  addNotification: async ({ userId, contentType, content, storyId, link }) => {
    4949    try {
    5050      await axios.post(`${API}/notifications`, {
    5151        content,
    52         recipientUserId,
    53         type,
     52        contentType,
     53        userId,
     54        storyId,
    5455        link,
    5556      }, { headers: getAuthHeaders() })
  • chapterx-frontend/src/store/storyStore.ts

    ra6e33d1 re882b92  
    144144        cover_image: s.image ?? undefined,
    145145        mature_content: s.matureContent,
    146         status: 'published' as StoryStatus,
     146        status: (s.status ?? 'draft') as StoryStatus,
    147147        author_username: s.writer?.user?.username ?? '',
    148148        created_at: s.createdAt,
     
    193193        name: c.name ?? c.username ?? '',
    194194        story_title: '',
    195         role: 'editor' as any,
    196         permission_level: 3 as any,
     195        role: c.role as any,
     196        permission_level: (c.permissionLevel ?? 3) as any,
    197197        joined_at: c.createdAt,
    198198      }))
     
    246246        image: imageUrl,
    247247        content: partial.content ?? story.content,
     248        status: partial.status ?? story.status,
    248249      }, { headers: getAuthHeaders() })
    249250    } catch {
     
    266267  },
    267268
    268   updateStoryStatus: (id, status) =>
     269  updateStoryStatus: (id, status) => {
    269270    set(state => ({
    270271      stories: state.stories.map(s =>
    271272        s.story_id === id ? { ...s, status, updated_at: new Date().toISOString() } : s
    272273      ),
    273     })),
     274    }))
     275    get().updateStory(id, { status })
     276  },
    274277
    275278  addChapter: async (chapter) => {
     
    407410        storyId: collab.story_id,
    408411        role: collab.role,
     412        permissionLevel: collab.permission_level,
    409413      }, { headers: getAuthHeaders() })
    410414    } catch {
     
    445449        original_text: s.originalText,
    446450        suggested_text: s.suggestedText,
    447         suggestion_type: (s.suggestionTypes?.[0] ?? 'style') as SuggestionType,
     451        suggestion_type: (s.suggestionType ?? 'style') as SuggestionType,
     452        explanation: s.explanation ?? '',
    448453        accepted: s.accepted === true ? true : s.accepted === false ? false : null,
     454        created_at: s.createdAt ?? new Date().toISOString(),
    449455        applied_at: s.appliedAt ?? undefined,
    450456      }))
     
    506512        originalText: suggestion.original_text,
    507513        suggestedText: suggestion.suggested_text,
     514        suggestionType: suggestion.suggestion_type,
    508515        storyId: suggestion.chapter_id,
    509516      }, { headers: getAuthHeaders() })
Note: See TracChangeset for help on using the changeset viewer.