46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
|
|
using BaseDomain;
|
|
using System.Globalization;
|
|
|
|
namespace ChatMvc.Domain
|
|
{
|
|
public class DateChanged : AValueObject
|
|
{
|
|
public DateChanged()
|
|
{
|
|
this.Value = DateTime.Now;
|
|
}
|
|
|
|
public DateChanged(DateTime dateTime)
|
|
{
|
|
this.Value = dateTime;
|
|
}
|
|
|
|
public DateChanged(string dateTime)
|
|
{
|
|
this.Value = Convert.ToDateTime(dateTime, new CultureInfo("pt-BR"));
|
|
}
|
|
|
|
public DateTime? Value { get; private set; }
|
|
|
|
public override bool GetValidationExpression()
|
|
{
|
|
IsValid = true;
|
|
if (Value == null)
|
|
{
|
|
IsValid = false;
|
|
}
|
|
return IsValid;
|
|
}
|
|
|
|
protected override IEnumerable<object> GetEqualityComponents()
|
|
{
|
|
yield return Value;
|
|
}
|
|
|
|
public static implicit operator string(DateChanged d) => d.Value.Value.ToString("pt-BR");
|
|
public static explicit operator DateChanged(DateTime b) => new DateChanged(b);
|
|
public static explicit operator DateChanged(string b) => new DateChanged(b);
|
|
}
|
|
}
|