82 lines
2.6 KiB
C#
82 lines
2.6 KiB
C#
using Code.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PrevuWebAPI.Models
|
|
{
|
|
public class APIContactModel
|
|
{
|
|
private Settings _settings = new Settings();
|
|
private string _first = "";
|
|
private string _last = "";
|
|
|
|
public string ContactFullName
|
|
{
|
|
get
|
|
{
|
|
if (_settings.GetSettingValue(_settings.NAME_FORMAT_SETTING_KEY) == FullNameFormat.LAST_FIRST.ToString())
|
|
{
|
|
return GetFullNameLastFirst();
|
|
}else
|
|
{
|
|
return GetFullNameFirstLast();
|
|
}
|
|
}
|
|
set
|
|
{
|
|
if (_settings.GetSettingValue(_settings.NAME_FORMAT_SETTING_KEY) == FullNameFormat.LAST_FIRST.ToString())
|
|
{
|
|
setFullNameLastFirst(value);
|
|
}
|
|
else
|
|
{
|
|
setFullNameFirstLast(value);
|
|
}
|
|
|
|
}
|
|
}
|
|
public string FirstName { get { return this._first; } set { this._first = value; } }
|
|
public string LastName { get { return this._last; } set { this._last = value; } }
|
|
private string GetFullNameFirstLast()
|
|
{
|
|
return this._first + " " + this._last;
|
|
}
|
|
private string GetFullNameLastFirst()
|
|
{
|
|
string delim = _settings.GetSettingValue(_settings.NAME_FORMAT_DELIM_SETTING_KEY);
|
|
return this._last + delim + this._first;
|
|
}
|
|
private void setFullNameFirstLast(string full)
|
|
{
|
|
if (full != null)
|
|
{
|
|
char delim = Char.Parse(_settings.GetSettingValue(_settings.NAME_FORMAT_DELIM_SETTING_KEY));
|
|
char[] splprm = { delim };
|
|
string[] parts = full.Split(splprm);
|
|
if (parts.Length == 2)
|
|
{
|
|
this._first = parts[0];
|
|
this._last = parts[1];
|
|
}
|
|
}
|
|
}
|
|
private void setFullNameLastFirst(string full)
|
|
{
|
|
if (full != null)
|
|
{
|
|
char delim = Char.Parse(_settings.GetSettingValue(_settings.NAME_FORMAT_DELIM_SETTING_KEY));
|
|
char[] splprm = { delim };
|
|
string[] parts = full.Split(splprm);
|
|
if (parts.Length == 2)
|
|
{
|
|
this._first = parts[0];
|
|
this._last = parts[1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|