Add per-user Like (پسندیدن) with a liked page and counts
CI/CD / CI · dotnet build (push) Successful in 2m54s
CI/CD / Deploy · hamkadr (push) Successful in 2m48s

Logged-in users can like a listing (job/shift/talent); dislike is removed per request — only likes.
- Like model (polymorphic by TargetType+TargetId) + EF migration; unique per (user, listing).
- POST /like toggles the like (auth required) and returns {liked, count}.
- Detail pages: the old ♡ Save / ✕ Dismiss buttons are replaced by a single heart Like button that
  shows the live count and toggles in place; clicking while logged out redirects to login.
- New «❤️ پسندیده‌ها» page (/Me/Liked) lists everything the user liked (open listings only), with a
  nav entry shown only when authenticated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-23 12:25:10 +03:30
parent 39c866f4c7
commit c1c914df9f
16 changed files with 2002 additions and 24 deletions
+3
View File
@@ -119,6 +119,9 @@ public enum ContactType
Other = 8 // سایر
}
/// <summary>What a <see cref="Like"/> points at.</summary>
public enum LikeTargetType { Shift = 0, Job = 1, Talent = 2 }
public enum ReportTargetType { Shift = 0, Job = 1, Facility = 2, User = 3 }
public enum ReportStatus { Open = 0, Resolved = 1, Dismissed = 2 }
+19
View File
@@ -0,0 +1,19 @@
namespace JobsMedical.Web.Models;
/// <summary>
/// A logged-in user's «پسندیدن» of a listing (shift / job / talent). One row per (user, listing);
/// toggling removes it. Polymorphic by <see cref="TargetType"/> + <see cref="TargetId"/> so one table
/// covers all three listing kinds. The count of rows for a target is the public "likes" number.
/// </summary>
public class Like
{
public int Id { get; set; }
public int UserId { get; set; }
public User User { get; set; } = null!;
public LikeTargetType TargetType { get; set; }
public int TargetId { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}