68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
namespace nsszcontactbot;
|
|
|
|
public class EmployeeContact
|
|
{
|
|
public static string GeneralPhoneNumber => "+78123352577";
|
|
public EmployeeContact(Employee employee)
|
|
{
|
|
FullName = employee.FullName;
|
|
var nameParts = FullName.Split(' ');
|
|
if (nameParts.Length > 1)
|
|
{
|
|
LastName = nameParts[0];
|
|
FirstName = nameParts[1];
|
|
}
|
|
else
|
|
{
|
|
FirstName = FullName;
|
|
LastName = string.Empty;
|
|
}
|
|
Department = employee.Department;
|
|
Position = employee.Position;
|
|
ExtensionNumber = employee.Phone ?? null; //string.IsNullOrEmpty(employee.Phone) ? null : employee.Phone;
|
|
Phone = string.IsNullOrEmpty(ExtensionNumber) ? GeneralPhoneNumber : $"{GeneralPhoneNumber},{ExtensionNumber}";
|
|
if (!string.IsNullOrEmpty(employee.Mobile))
|
|
{
|
|
Mobile = employee.Mobile;
|
|
if (!Mobile.StartsWith('+'))
|
|
Mobile = "+" + Mobile;
|
|
}
|
|
Mail = employee.Mail;
|
|
}
|
|
|
|
public string VCard
|
|
{
|
|
get
|
|
{
|
|
string text = "BEGIN:VCARD\n"
|
|
+ "VERSION:2.1\n"
|
|
+ $"N:{LastName};{FirstName}\n"
|
|
+ $"FN:{FullName}\n"
|
|
+ "ORG:NSSZ\n"
|
|
+ $"ROLE:{Department}\n"
|
|
+ $"TITLE:{Position}\n";
|
|
if (!string.IsNullOrEmpty(Mobile))
|
|
text += $"TEL;CELL:{Mobile}\n";
|
|
|
|
if (!string.IsNullOrEmpty(Phone))
|
|
text += $"TEL;WORK:{Phone}\n";
|
|
|
|
if (!string.IsNullOrEmpty(Mail))
|
|
text += $"EMAIL;WORK:{Mail}\n";
|
|
|
|
text += "PRODID:nssz-contact-bot\n";
|
|
text += "END:VCARD\n";
|
|
return text;
|
|
}
|
|
}
|
|
public string FullName { get; set; } // Полное имя сотрудника
|
|
public string FirstName { get; set; }
|
|
public string LastName { get; set; }
|
|
public string Department { get; set; } // Название отдела
|
|
public string Position { get; set; } // Должность
|
|
public string Phone { get; set; }
|
|
public string? ExtensionNumber { get; set; }
|
|
public string? Mobile { get; set; } // Опциональное поле для хранения номера мобильного телефона
|
|
public string? Mail { get; set; } // Опциональное поле для электронной почты
|
|
}
|