2026-06-08 08:01:12 +03:30
|
|
|
using JobsMedical.Web.Data;
|
|
|
|
|
using JobsMedical.Web.Models;
|
|
|
|
|
using JobsMedical.Web.Services.Scraping;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace JobsMedical.Web.Pages.Talent;
|
|
|
|
|
|
|
|
|
|
public class IndexModel : PageModel
|
|
|
|
|
{
|
|
|
|
|
private readonly AppDbContext _db;
|
|
|
|
|
public IndexModel(AppDbContext db) => _db = db;
|
|
|
|
|
|
|
|
|
|
[BindProperty(SupportsGet = true)] public int? CityId { get; set; }
|
|
|
|
|
[BindProperty(SupportsGet = true)] public int? DistrictId { get; set; }
|
|
|
|
|
[BindProperty(SupportsGet = true)] public int? RoleId { get; set; }
|
|
|
|
|
[BindProperty(SupportsGet = true)] public Gender? GenderFilter { get; set; }
|
2026-06-08 11:25:32 +03:30
|
|
|
[BindProperty(SupportsGet = true)] public string? Q { get; set; } // deep search
|
2026-06-08 08:01:12 +03:30
|
|
|
|
|
|
|
|
public List<TalentListing> Results { get; private set; } = new();
|
|
|
|
|
public List<City> Cities { get; private set; } = new();
|
|
|
|
|
public List<District> Districts { get; private set; } = new();
|
|
|
|
|
public List<Role> Roles { get; private set; } = new();
|
|
|
|
|
|
|
|
|
|
public async Task OnGetAsync()
|
|
|
|
|
{
|
|
|
|
|
Cities = await _db.Cities.Where(c => c.IsActive).OrderBy(c => c.Name).ToListAsync();
|
|
|
|
|
Roles = await _db.Roles.Where(r => r.IsActive).OrderBy(r => r.SortOrder).ToListAsync();
|
|
|
|
|
Districts = await _db.Districts
|
|
|
|
|
.Where(d => d.IsActive && (CityId == null || d.CityId == CityId))
|
|
|
|
|
.OrderBy(d => d.Name).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var q = _db.TalentListings
|
|
|
|
|
.Include(t => t.City)
|
|
|
|
|
.Include(t => t.District)
|
|
|
|
|
.Include(t => t.Role)
|
2026-06-08 08:59:54 +03:30
|
|
|
.Where(t => t.Status == ShiftStatus.Open && t.CreatedAt >= ListingPolicy.TalentCutoffUtc);
|
2026-06-08 08:01:12 +03:30
|
|
|
|
|
|
|
|
if (CityId is not null) q = q.Where(t => t.CityId == CityId);
|
|
|
|
|
if (DistrictId is not null) q = q.Where(t => t.DistrictId == DistrictId);
|
|
|
|
|
if (RoleId is not null) q = q.Where(t => t.RoleId == RoleId);
|
|
|
|
|
if (GenderFilter is Gender g && g != Gender.Any)
|
|
|
|
|
q = q.Where(t => t.Gender == Gender.Any || t.Gender == g);
|
|
|
|
|
|
2026-06-08 11:25:32 +03:30
|
|
|
// Deep search: every term must match somewhere (tags, role, city, person, area, description).
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Q))
|
|
|
|
|
foreach (var term in Q.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
|
|
|
|
|
{
|
|
|
|
|
var like = $"%{term}%";
|
|
|
|
|
q = q.Where(t =>
|
|
|
|
|
EF.Functions.ILike(t.Tags ?? "", like) ||
|
|
|
|
|
EF.Functions.ILike(t.Description ?? "", like) ||
|
|
|
|
|
EF.Functions.ILike(t.PersonName ?? "", like) ||
|
|
|
|
|
EF.Functions.ILike(t.AreaNote ?? "", like) ||
|
|
|
|
|
EF.Functions.ILike(t.Role.Name, like) ||
|
|
|
|
|
EF.Functions.ILike(t.City.Name, like));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-08 08:01:12 +03:30
|
|
|
Results = await q.OrderByDescending(t => t.CreatedAt).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|