/// <summary> /// Calculate contact age. /// </summary> /// <returns>Contact age</returns> protected virtual int CalculateContactAge() { DateTime birthDate = Entity.GetTypedColumnValue <DateTime>("Date"); CalculateAgeHelper actualizeAgeHelper = ClassFactory.Get <CalculateAgeHelper>(); return(actualizeAgeHelper.GetFullAgeYears(birthDate)); }
/// <summary> /// Set current contact age, if it needed. /// </summary> public virtual void UpdateContactAge() { if (IsNotNeededToCalculateAge()) { return; } DateTime birthDate = Entity.GetTypedColumnValue <DateTime>("BirthDate"); CalculateAgeHelper actualizeAgeHelper = ClassFactory.Get <CalculateAgeHelper>(); int age = actualizeAgeHelper.GetFullAgeYears(birthDate); if (age >= 0) { Entity.SetColumnValue("Age", age); } }