Add hiring, AI parser+admin, OTP auth, employer dashboard, profit-share pay
- Hiring (استخدام) listings: JobOpening + /Jobs browse/detail + home section - Heuristic Persian listing-parser + admin queue (/Admin) → publish shift/job - Phone-OTP cookie auth + visitor-history linking + profile; Admin role gate - Employer side: self-serve facility registration, dashboard, post/manage shifts & jobs, applicants list with contact - Compensation models: fixed / hourly / profit-share (درصدی) / negotiable / choice (به انتخاب شما); SharePercent + JalaliDate.PayLabel; parser + filter Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System.Security.Claims;
|
||||
using JobsMedical.Web.Data;
|
||||
using JobsMedical.Web.Models;
|
||||
using JobsMedical.Web.Services;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace JobsMedical.Web.Pages.Employer;
|
||||
|
||||
[Authorize]
|
||||
public class RegisterFacilityModel : PageModel
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
public RegisterFacilityModel(AppDbContext db) => _db = db;
|
||||
|
||||
public List<City> Cities { get; private set; } = new();
|
||||
public List<District> Districts { get; private set; } = new();
|
||||
|
||||
[BindProperty] public string Name { get; set; } = "";
|
||||
[BindProperty] public FacilityType Type { get; set; }
|
||||
[BindProperty] public int CityId { get; set; }
|
||||
[BindProperty] public int? DistrictId { get; set; }
|
||||
[BindProperty] public string? Address { get; set; }
|
||||
[BindProperty] public string? Phone { get; set; }
|
||||
[BindProperty] public string? BaleId { get; set; }
|
||||
[BindProperty] public double? Lat { get; set; }
|
||||
[BindProperty] public double? Lng { get; set; }
|
||||
public string? Error { get; private set; }
|
||||
|
||||
public async Task OnGetAsync() => await LoadListsAsync();
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
await LoadListsAsync();
|
||||
if (string.IsNullOrWhiteSpace(Name) || CityId == 0)
|
||||
{
|
||||
Error = "نام مرکز و شهر الزامی است.";
|
||||
return Page();
|
||||
}
|
||||
|
||||
var userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
|
||||
var facility = new Facility
|
||||
{
|
||||
Name = Name.Trim(),
|
||||
Type = Type,
|
||||
CityId = CityId,
|
||||
DistrictId = DistrictId,
|
||||
Address = Address?.Trim(),
|
||||
Phone = Phone?.Trim(),
|
||||
BaleId = BaleId?.Trim(),
|
||||
Lat = Lat,
|
||||
Lng = Lng,
|
||||
OwnerUserId = userId,
|
||||
IsVerified = false, // platform verifies later
|
||||
};
|
||||
_db.Facilities.Add(facility);
|
||||
|
||||
// Promote the user to FacilityAdmin (keep Admin if already admin) and refresh the cookie.
|
||||
var user = await _db.Users.FindAsync(userId);
|
||||
if (user is not null && user.Role == UserRole.Doctor)
|
||||
{
|
||||
user.Role = UserRole.FacilityAdmin;
|
||||
await _db.SaveChangesAsync();
|
||||
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
|
||||
AuthHelper.BuildPrincipal(user));
|
||||
}
|
||||
else
|
||||
{
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return RedirectToPage("/Employer/Index");
|
||||
}
|
||||
|
||||
private async Task LoadListsAsync()
|
||||
{
|
||||
Cities = await _db.Cities.OrderByDescending(c => c.IsActive).ThenBy(c => c.Name).ToListAsync();
|
||||
Districts = await _db.Districts.Where(d => d.IsActive).OrderBy(d => d.Name).ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user