public void CheckDate(DateTime date) { var age = DateTime.Today.Date.Year - date.Date.Year; OperateZodiac zodiac = new OperateZodiac(); if (zodiac.isBirthday(date.Date)) { MessageBox.Show("Вітаємо з днем народження!"); } try { Person TestPerson = new Models.Person(); TestPerson.IsCorrectDateOfBirth(date); if (TestPerson.IsEmailValid(_email)) { MessageBox.Show("Email правильний"); } else { throw new IllegalEmailException(); } } catch (Exception e) { MessageBox.Show(e.Message); } Person _mainPerson = new Person(_email, _name, _surname, date); _loginModel._storage.ChangeInfo(_mainPerson); }
public Person(string name, string surname, string email, DateTime dateOfBirth) { IsCorrectDateOfBirth(dateOfBirth); IsEmailValid(email); Name = name; Surname = surname; Email = email; DateOfBirth = dateOfBirth; OperateZodiac zodiac = new OperateZodiac(); _isAdult = CalcAdult(); _sunSign = zodiac.FindWestZodiac(DateOfBirth); _chineseSign = zodiac.FindChineseZodiac(DateOfBirth.Year); _isBirthday = zodiac.isBirthday(DateOfBirth); }
public void CheckDate(DateTime date) { var age = DateTime.Today.Date.Year - date.Date.Year; OperateZodiac zodiac = new OperateZodiac(); if (zodiac.isBirthday(date.Date)) { MessageBox.Show("Вітаємо з днем народження!"); } IsCorrectDateOfBirth(date); IsEmailValid(_surname); Person _mainPerson = new Person(_email, _name, _surname, date); LModel._storage.ChangeInfo(_mainPerson); }
public Person(string email, string name, string surname, DateTime dateOfBirth) { Email = email; Name = name; Surname = surname; DateOfBirth = dateOfBirth; OperateZodiac zodiac = new OperateZodiac(); _westernZodiac = zodiac.FindWestZodiac(DateOfBirth); _chineseZodiac = zodiac.FindChineseZodiac(DateOfBirth.Year); _isBirthday = zodiac.isBirthday(DateOfBirth); if (DateTime.Today > DateOfBirth) { if (DateTime.Today.Month > DateOfBirth.Month) { Age = DateTime.Today.Year - DateOfBirth.Year; } else if (DateTime.Today.Month == DateOfBirth.Month && DateTime.Today.Day > DateOfBirth.Day) { Age = DateTime.Today.Year - DateOfBirth.Year; } else if (DateTime.Today.Month == DateOfBirth.Month && DateTime.Today.Day == DateOfBirth.Day) { Age = DateTime.Today.Year - DateOfBirth.Year; } else { Age = DateTime.Today.Year - DateOfBirth.Year - 1; } } else { Age = 0; } _isAdult = CalcAdult(); }