async Task CreateAndShowPersonFromInputedData(object o) { Console.WriteLine(DateOfBirth); if (DateOfBirthday.DateOfBirthIsTrue(DateOfBirth) == false) { MessageBox.Show("Enter a valid date!", "error", MessageBoxButton.OKCancel, MessageBoxImage.Error); return; } if (DateOfBirthday.IsBirthday(DateOfBirth)) { MessageBox.Show("Wow, it's your birthday! Go enjoy yourself.", "your only invite today", MessageBoxButton.OK, MessageBoxImage.Asterisk); } if (!EmailValidator.IsValidFormat(Email)) { MessageBox.Show("The email is badly formatted!", "error", MessageBoxButton.OKCancel, MessageBoxImage.Error); return; } // cannot access DataContext from non-ui thread // and anyway, creating the new thread would take more time that just execution this code var person = new Person(Name, Surname, Email, DateOfBirth); var personInfoVM = new PersonInfoViewModel(person); _personInfoGrid.DataContext = personInfoVM; _personInfoGrid.Visibility = Visibility.Visible; }
internal Person(string name, string surname, string email, DateTime dateOfBirth) : this(name, surname, email) { if (!DateOfBirthday.DateOfBirthIsTrue(dateOfBirth)) { throw new ArgumentOutOfRangeException(nameof(dateOfBirth)); } DateOfBirth = dateOfBirth; }
public override string ToString() { return($"{Id} {Name} {DateOfBirthday.ToShortDateString()} {Age}"); }
public override string ToString() { return($"{ LastName } { FirstName } { MiddleName }, { DateOfBirthday.ToShortDateString() }"); }