2026-06-03 01:43:55 +03:30
|
|
|
using JobsMedical.Web.Data;
|
|
|
|
|
using JobsMedical.Web.Models;
|
|
|
|
|
using JobsMedical.Web.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace JobsMedical.Web.Pages.Jobs;
|
|
|
|
|
|
|
|
|
|
public class DetailsModel : PageModel
|
|
|
|
|
{
|
|
|
|
|
private readonly AppDbContext _db;
|
|
|
|
|
private readonly InterestService _interest;
|
2026-06-04 18:57:49 +03:30
|
|
|
private readonly JobsMedical.Web.Services.Scraping.SettingsService _settings;
|
2026-06-03 01:43:55 +03:30
|
|
|
|
2026-06-04 18:57:49 +03:30
|
|
|
public DetailsModel(AppDbContext db, InterestService interest,
|
|
|
|
|
JobsMedical.Web.Services.Scraping.SettingsService settings)
|
2026-06-03 01:43:55 +03:30
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
_interest = interest;
|
2026-06-04 18:57:49 +03:30
|
|
|
_settings = settings;
|
2026-06-03 01:43:55 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JobOpening? Job { get; private set; }
|
2026-06-04 18:57:49 +03:30
|
|
|
public string? MapKey { get; private set; }
|
2026-06-03 01:43:55 +03:30
|
|
|
public bool ShowContact { get; private set; }
|
|
|
|
|
public bool Saved { get; private set; }
|
2026-06-04 13:19:20 +03:30
|
|
|
public bool Reported { get; private set; }
|
2026-06-03 01:43:55 +03:30
|
|
|
|
|
|
|
|
public async Task<IActionResult> OnGetAsync(int id)
|
|
|
|
|
{
|
|
|
|
|
await LoadAsync(id);
|
|
|
|
|
if (Job is null) return NotFound();
|
2026-06-04 18:57:49 +03:30
|
|
|
MapKey = (await _settings.GetAsync()).NeshanMapKey;
|
2026-06-04 13:19:20 +03:30
|
|
|
Reported = Request.Query["reported"] == "1";
|
2026-06-03 01:43:55 +03:30
|
|
|
await _interest.LogJobAsync(InterestEventType.View, id);
|
|
|
|
|
return Page();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> OnPostInterestAsync(int id)
|
|
|
|
|
{
|
|
|
|
|
await LoadAsync(id);
|
|
|
|
|
if (Job is null) return NotFound();
|
|
|
|
|
await _interest.LogJobAsync(InterestEventType.Apply, id);
|
|
|
|
|
ShowContact = true;
|
|
|
|
|
return Page();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> OnPostSaveAsync(int id)
|
|
|
|
|
{
|
|
|
|
|
await LoadAsync(id);
|
|
|
|
|
if (Job is null) return NotFound();
|
|
|
|
|
await _interest.LogJobAsync(InterestEventType.Save, id);
|
|
|
|
|
Saved = true;
|
|
|
|
|
return Page();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> OnPostDismissAsync(int id)
|
|
|
|
|
{
|
|
|
|
|
await _interest.LogJobAsync(InterestEventType.Dismiss, id);
|
|
|
|
|
return RedirectToPage("/Jobs/Index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task LoadAsync(int id)
|
|
|
|
|
{
|
|
|
|
|
Job = await _db.JobOpenings
|
|
|
|
|
.Include(j => j.Facility).ThenInclude(f => f.City)
|
|
|
|
|
.Include(j => j.Facility).ThenInclude(f => f.District)
|
|
|
|
|
.Include(j => j.Role)
|
|
|
|
|
.FirstOrDefaultAsync(j => j.Id == id);
|
|
|
|
|
}
|
|
|
|
|
}
|