using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SimpleValidator.Extensions; namespace Tango.BL.Entities { public partial class Contact : ContactBase { protected override void RaisePropertyChanged(string propName) { base.RaisePropertyChanged(propName); if (propName == nameof(FirstName) || propName == nameof(LastName)) { NormalizeNames(); } } private void NormalizeNames() { if (_firstname != null) { _firstname = _firstname.Trim(); } if (_lastname != null) { _lastname = _lastname.Trim(); } FullName = FirstName + " " + LastName; } protected override void OnValidating(ObservablesContext context) { base.OnValidating(context); if (FirstName.IsNullOrWhiteSpace() || LastName.IsNullOrWhiteSpace()) { InsertError(nameof(FirstName), "Contact first name and last name was not provided."); } if (!Email.IsEmail()) { InsertError(nameof(Email), "Invalid contact email format."); } } /// /// Initializes a new instance of the class. /// public Contact() : base() { } } }