Skip to content

Applying Soft Delete & integrate user identity#12

Merged
hadeer-r merged 10 commits into
Askfm-clone:Developfrom
hadeer-r:SoftDelete-userIdentity
Aug 13, 2025
Merged

Applying Soft Delete & integrate user identity#12
hadeer-r merged 10 commits into
Askfm-clone:Developfrom
hadeer-r:SoftDelete-userIdentity

Conversation

@hadeer-r
Copy link
Copy Markdown
Contributor

@hadeer-r hadeer-r commented Aug 10, 2025

Changes

  1. Adding ITrackable interface
  2. move all Delete Behaviours to No Action
  3. Implement the IdentityUser interface in the app and change the name of the User Entity to ApplicationUser.

Summary by CodeRabbit

  • New Features

    • Integrated ASP.NET Core Identity for enhanced user authentication and role management.
    • Introduced soft delete functionality, allowing users and content (threads, comments, likes, notifications, follows, saved threads) to be marked as deleted without permanent removal.
  • Improvements

    • Updated user-related entities and relationships to support ASP.NET Identity conventions.
    • Modified delete behaviors across the platform to prevent automatic removal of related data, improving data integrity and recoverability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 10, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update integrates ASP.NET Core Identity into the application, replacing the custom User entity with ApplicationUser inheriting from IdentityUser<int>. It introduces soft-delete support via an ITrackable interface and corresponding properties across multiple models. Database migrations and configurations are updated to reflect these changes, including schema adjustments and altered foreign key behaviors.

Changes

Cohort / File(s) Change Summary
Identity Integration & User Model Refactor
AskFm.DAL/Models/ApplicationUser.cs, AskFm.DAL/ModelsConfigrations/ApplicationUserConfigration.cs, AskFm.API/Program.cs, AskFm.DAL/AppDbContext.cs, AskFm.DAL/Migrations/20250810034350_using_identity.cs, AskFm.DAL/Migrations/20250810034350_using_identity.Designer.cs, AskFm.DAL/Migrations/AppDbContextModelSnapshot.cs
Replaced custom User entity with ApplicationUser inheriting from IdentityUser<int>, updated configuration, registered Identity services, and migrated database schema to ASP.NET Identity conventions.
Soft Delete Implementation
AskFm.DAL/Models/ITrackable.cs, AskFm.DAL/Models/Comment.cs, AskFm.DAL/Models/CommentLike.cs, AskFm.DAL/Models/Follow.cs, AskFm.DAL/Models/Notification.cs, AskFm.DAL/Models/SavedThreads.cs, AskFm.DAL/Models/Thread.cs, AskFm.DAL/Models/ThreadLike.cs, AskFm.DAL/AppDbContext.cs, AskFm.DAL/Migrations/20250810015924_Soft_Delete.cs, AskFm.DAL/Migrations/20250810015924_Soft_Delete.Designer.cs, AskFm.DAL/Migrations/AppDbContextModelSnapshot.cs
Introduced ITrackable interface and implemented soft-delete properties (IsDeleted, DeletedAt) in all major domain models. Updated context and migrations to handle soft-delete fields.
Foreign Key Delete Behavior Adjustments
AskFm.DAL/ModelsConfigrations/CommentConfigration.cs, AskFm.DAL/ModelsConfigrations/CommentLikeConfigration.cs, AskFm.DAL/ModelsConfigrations/NotificationConfigration.cs, AskFm.DAL/ModelsConfigrations/ThreadConfigration.cs, AskFm.DAL/ModelsConfigrations/ThreadLikeConfigration.cs, AskFm.DAL/Migrations/20250810021444_set_no_action_OnDelete.cs, AskFm.DAL/Migrations/20250810021444_set_no_action_OnDelete.Designer.cs, AskFm.DAL/Migrations/AppDbContextModelSnapshot.cs
Changed foreign key delete behaviors from Cascade or ClientSetNull to NoAction in entity configurations and migrations, preventing automatic deletions of related entities.
Project Dependency Updates
AskFm/AskFm.API/AskFm.API.csproj, AskFm/AskFm.DAL/AskFm.DAL.csproj
Added Microsoft.AspNetCore.Identity.EntityFrameworkCore package reference to both API and DAL projects.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant Identity
    participant DbContext

    Client->>API: Registers or logs in
    API->>Identity: Uses ApplicationUser (IdentityUser<int>)
    Identity->>DbContext: Stores/Retrieves user data
    DbContext-->>Identity: Returns user/role info
    Identity-->>API: Authentication result
    API-->>Client: Response
Loading
sequenceDiagram
    participant Service
    participant DbContext
    participant Entity (ITrackable)

    Service->>DbContext: Soft-delete entity
    DbContext->>Entity: Set IsDeleted = true, DeletedAt = now
    DbContext->>Database: Update entity record
    Database-->>DbContext: Acknowledgement
    DbContext-->>Service: Operation complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

Oh, what a hop through code today,
Identity lands, old users give way.
Soft deletes now gently sweep,
Marking records, not too deep.
Foreign keys hold on tight,
No more cascade in the night.
🐇 Cheers to progress—what a sight!

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hadeer-r
Copy link
Copy Markdown
Contributor Author

@coderabbitai summary

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 10, 2025

✅ Actions performed

Summary regeneration triggered.

Comment thread AskFm/AskFm.DAL/Models/ITrackable.cs
Comment thread AskFm/AskFm.DAL/Models/Notification.cs Outdated
@hadeer-r hadeer-r merged commit 89ff6fb into Askfm-clone:Develop Aug 13, 2025
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Sep 4, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants