using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using gehGassiApp.Domain.Base;
using gehGassiApp.Domain.Common;
namespace gehGassiApp.Domain.Lookup
{
///
/// Lookup für dogOwner und DogWalker
///
public class AppUserLookup : SyncEntity
{
///
/// Vorname
///
public string FirstName { get; set; }
///
/// Nachname
///
public string LastName { get; set; }
///
/// Optional - Foto des Benutzers
///
public string Photo { get; set; }
///
/// Typ der Entität
///
public AppUserType Type { get; set; }
///
/// Hinweis auf den Ort wo jemand zu Hause ist
///
public string LocationHint { get; set; }
///
/// Breitengrad der Adresse
///
public double Lat { get; set; }
///
/// Längengrad der Adresse
///
public double Lng { get; set; }
///
/// Distanz zum Lookup
///
public double Distance { get; set; }
///
/// Gibt die Initialien zurück
///
public string Initials
{
get
{
if (!string.IsNullOrWhiteSpace(FirstName) && !string.IsNullOrWhiteSpace(LastName))
return $"{FirstName.Substring(0, 1)}{LastName.Substring(0, 1)}";
else if(!string.IsNullOrWhiteSpace(FirstName) && FirstName.Length >= 2 && string.IsNullOrWhiteSpace(LastName))
return $"{FirstName.Substring(0, 2)}";
else if (string.IsNullOrWhiteSpace(FirstName) && string.IsNullOrWhiteSpace(LastName) && LastName.Length >= 2)
return $"{LastName.Substring(0, 2)}";
else
return "??";
}
}
///
/// Voller Name
///
public string FullName => $"{FirstName} {LastName}";
///
/// Vorname + Nachname erster Buchstabe + Punkt, oder nur Vorname wenn kein Nachname
///
[NotMapped]
public string FullNameShort => string.IsNullOrWhiteSpace(LastName) ? FirstName : $"{FirstName} {LastName[..1]}.";
}
}