e4dc5180ad
- ContactMethod entity (Type + Value + SortOrder) 1→N on TalentListing (+ migration). - Parser extracts ALL contacts: multiple phones + landlines, email, and socials (Instagram/Telegram/Bale/WhatsApp/website) via URLs and Persian keyword cues; primary Phone kept for cards. - ContactInfo helper: per-type label/icon/clickable href (tel:/mailto:/t.me/…). - Ingestion attaches contacts to each (fanned-out) talent listing; manual Review re-parses to attach them + the admin-typed phone. - Talent details renders the full contact list as buttons; falls back to the single phone, then the Divar source link. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using System.Linq;
|
|
using JobsMedical.Web.Models;
|
|
|
|
namespace JobsMedical.Web.Services;
|
|
|
|
/// <summary>Presentation helpers for <see cref="ContactType"/> — label, icon, and a clickable href.</summary>
|
|
public static class ContactInfo
|
|
{
|
|
public static string Label(ContactType t) => t switch
|
|
{
|
|
ContactType.Mobile => "موبایل",
|
|
ContactType.Phone => "تلفن ثابت",
|
|
ContactType.Email => "ایمیل",
|
|
ContactType.Telegram => "تلگرام",
|
|
ContactType.Bale => "بله",
|
|
ContactType.WhatsApp => "واتساپ",
|
|
ContactType.Instagram => "اینستاگرام",
|
|
ContactType.Website => "وبسایت",
|
|
_ => "تماس",
|
|
};
|
|
|
|
public static string Icon(ContactType t) => t switch
|
|
{
|
|
ContactType.Mobile or ContactType.Phone => "📞",
|
|
ContactType.Email => "✉️",
|
|
ContactType.Telegram => "📨",
|
|
ContactType.Bale => "💬",
|
|
ContactType.WhatsApp => "🟢",
|
|
ContactType.Instagram => "📷",
|
|
ContactType.Website => "🌐",
|
|
_ => "🔗",
|
|
};
|
|
|
|
/// <summary>A clickable URL for the contact (tel:/mailto:/t.me/…), or null when not linkable.</summary>
|
|
public static string? Href(ContactType t, string value)
|
|
{
|
|
var v = value.Trim();
|
|
var handle = v.TrimStart('@');
|
|
string Digits() => new(v.Where(char.IsDigit).ToArray());
|
|
return t switch
|
|
{
|
|
ContactType.Mobile or ContactType.Phone => "tel:" + Digits(),
|
|
ContactType.Email => "mailto:" + v,
|
|
ContactType.Telegram => "https://t.me/" + handle,
|
|
ContactType.Bale => "https://ble.ir/" + handle,
|
|
ContactType.WhatsApp => "https://wa.me/" + Digits(),
|
|
ContactType.Instagram => "https://instagram.com/" + handle,
|
|
ContactType.Website => v.StartsWith("http") ? v : "https://" + v,
|
|
_ => null,
|
|
};
|
|
}
|
|
}
|