public override string ToString() { return("\nFirst name: " + FirstName + "\nLast name: " + LastName + "\nBirth date: " + BirthDate.ToString("d") + "\nTax number: " + TaxNumber + "\nUniversity name: " + UniversityName + "\nUniversity admission date: " + UniversityAdmissionDate.ToString("d") + "\n"); }
public void Equals_ValuesNotEqual_False() { var birthDateDT = new BirthDate(DateTime.Now - new TimeSpan(30 * 365, 0, 0, 0)); var birthDateDT2 = new BirthDate(DateTime.Now - new TimeSpan(31 * 365, 0, 0, 0)); Assert.IsFalse(birthDateDT.Equals(birthDateDT2)); }
/// <summary> /// To the claims. /// </summary> /// <returns>IEnumerable<Claim>.</returns> public IEnumerable <Claim> ToClaims() { var claims = new List <Claim>(); if (!string.IsNullOrEmpty(RealName)) { claims.Add(new Claim(JwtClaimTypes.GivenName, RealName)); } if (!string.IsNullOrEmpty(NickName)) { claims.Add(new Claim(JwtClaimTypes.NickName, NickName)); } if (!string.IsNullOrEmpty(AvatarUrl)) { claims.Add(new Claim(JwtClaimTypes.Picture, AvatarUrl)); } if (!string.IsNullOrEmpty(QQ)) { claims.Add(new Claim(OAuthClaimTypes.QQ, QQ)); } if (!string.IsNullOrEmpty(WX)) { claims.Add(new Claim(OAuthClaimTypes.WX, WX)); } if (!string.IsNullOrEmpty(WChat)) { claims.Add(new Claim(OAuthClaimTypes.WChat, WChat ?? "")); } claims.Add(new Claim(JwtClaimTypes.Gender, ((int)Gender).ToString())); claims.Add(new Claim(JwtClaimTypes.BirthDate, BirthDate.ToString("yyyy-MM-dd hh:mm:ss"))); return(claims); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine($"{ID} {Gender} '{Name}' '{Address}' {BirthDate.ToShortDateString()}"); return($"{sb}"); }
public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } if (obj.GetType() != this.GetType()) { return(false); } Employee other = (Employee)obj; return(EmployeeId == other.EmployeeId && PositionId == other.PositionId && string.Equals(FirstName, other.FirstName) && string.Equals(LastName, other.LastName) && string.Equals(Patronymic, other.Patronymic) && BirthDate.Equals(other.BirthDate) && string.Equals(Address, other.Address) && string.Equals(Phone, other.Phone) && string.Equals(Education, other.Education) && EmploymentDate.Equals(other.EmploymentDate) && Deleted == other.Deleted); }
public override int GetHashCode() { int prime = 31; int result = 1; result = prime * result + Id.BitShiftThenBitOr(prime); result = prime * result + Name.StringToInt().BitShiftThenBitOr(prime); result = prime * result + Gender.GenderToInt().BitShiftThenBitOr(prime); result = prime * result + BirthDate.DateToInt().BitShiftThenBitOr(prime); result = prime * result + Email.StringToInt().BitShiftThenBitOr(prime); result = prime * result + Phone.StringToInt().BitShiftThenBitOr(prime); result = prime * result + ZipCode.BitShiftThenBitOr(prime); result = prime * result + Address.StringToInt().BitShiftThenBitOr(prime); result = prime * result + UserName.StringToInt().BitShiftThenBitOr(prime); result = prime * result + Password.StringToInt().BitShiftThenBitOr(prime); result = prime * result + Pin.BitShiftThenBitOr(prime); result = prime * result + LoginIP.StringToInt().BitShiftThenBitOr(prime); result = prime * result + MacAddress.StringToInt().BitShiftThenBitOr(prime); result = prime * result + StartingDate.DateToInt().BitShiftThenBitOr(prime); result = prime * result + Access.AccessToInt().BitShiftThenBitOr(prime); result = prime * result + AccountPriority.AccountPriorityToInt().BitShiftThenBitOr(prime); result = prime * result + MembershipType.MembershipToInt().BitShiftThenBitOr(prime); result = prime * result + Email.StringToInt().BitShiftThenBitOr(prime); result = prime * result + BirthDate.ToString().StringToInt().BitShiftThenBitOr(prime); result = prime * result + LastLogin.DateToInt().BitShiftThenBitOr(prime); result = prime * result + LastLogout.DateToInt().BitShiftThenBitOr(prime); result = prime * result + Age.BitShiftThenBitOr(prime); return(result); }
public override int GetHashCode() { unchecked { var hashCode = Id; hashCode = (hashCode * 397) ^ (LastName != null ? LastName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TitleOfCourtesy != null ? TitleOfCourtesy.GetHashCode() : 0); hashCode = (hashCode * 397) ^ BirthDate.GetHashCode(); hashCode = (hashCode * 397) ^ HireDate.GetHashCode(); hashCode = (hashCode * 397) ^ (Address != null ? Address.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Region != null ? Region.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HomePhone != null ? HomePhone.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Extension != null ? Extension.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Photo != null ? Photo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Notes != null ? Notes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ReportsTo.GetHashCode(); hashCode = (hashCode * 397) ^ (PhotoPath != null ? PhotoPath.GetHashCode() : 0); return(hashCode); } }
public async Task <Result <Author> > Handle(CreateAuthorCommand command) { Result <Name> nameResult = Name.Create(command.FirstName, command.LastName); if (nameResult.IsFailure) { return(Result.Failure <Author>(nameResult.Error)); } Result <BirthDate> birthDateResult = BirthDate.Create(command.DateOfBirth); if (birthDateResult.IsFailure) { return(Result.Failure <Author>(birthDateResult.Error)); } Result <MainCategory> mainCategoryResult = Entities.Authors.MainCategory.Create(command.MainCategory); if (mainCategoryResult.IsFailure) { return(Result.Failure <Author>(mainCategoryResult.Error)); } var author = new Author(nameResult.Value, birthDateResult.Value, null, mainCategoryResult.Value); //author.AddBooks(command.Books); await _unitOfWork.AuthorRepository.AddAsync(author); await _unitOfWork.SaveChangesAsync(); return(Result.Success(author)); }
// Fill Basic info page public void ViewBasicInfo() { //////////// P_ID.Text = Patient_ID.ToString(); P_Name.Text = Patient_Name; P_Age.Text = Age.ToString(); P_Sex.Text = Sex; P_Birthday.Text = BirthDate.ToShortDateString(); P_Home_no.Text = Home_no; P_Mobile_nom.Text = Mobile_no; P_Visit_date.Text = VisitDate.ToShortDateString(); P_Realative_Marriage.Text = RelativeMarriage; P_Address.Text = Address; P_Chief_Comp.Text = Cheif_comp; P_Medical_Alert.Text = Medical_Alr; if (Comments != null) { P_Comments.Text = Comments; } PatientPhoto = Patient.Patient_image; MemoryStream ms = new MemoryStream(PatientPhoto); var image = Image.FromStream(ms); P_Profile_Picture.Image = image; P_Profile_Picture.SizeMode = PictureBoxSizeMode.StretchImage; }
/// <summary> /// Serves as the default hash object /// </summary> /// <returns></returns> public override int GetHashCode() { var hashCode = 1867947502; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FirstName); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(LastName); hashCode = hashCode * -1521134295 + BirthDate.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Height); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PrimaryPosition); hashCode = hashCode * -1521134295 + IsStarter.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Interests); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Address); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(City); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(State); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Zipcode); return(hashCode); }
public void SaveToXML() { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; DirectoryInfo di = Directory.CreateDirectory(XmlFolder); string path = XmlFolder + FullName + ".xml"; using (XmlWriter writer = XmlWriter.Create(path, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("person"); writer.WriteAttributeString("gender", Gender == 'm' ? "male" : "female"); writer.WriteStartElement("name"); writer.WriteElementString("firstname", FirstName); writer.WriteElementString("lastname", LastName); writer.WriteEndElement(); writer.WriteElementString("birthdate", BirthDate.ToString("yyyy/mm/dd")); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } }
public void Setup() { this.firstName = new Name("Jhon"); this.lastName = new Name("Smith"); this.birthDate = new BirthDate(new DateTime(1980, 1, 1)); this.mockRepository = new Mock <IContactRepository>(); }
public void Equality() { Assert.Equal( new Employee("a", "b", BirthDate.From("1980-02-14"), "c"), new Employee("a", "b", BirthDate.From("1980-02-14"), "c") ); }
public override int GetHashCode() { int hash = FirstName.GetHashCode() ^ LastName.GetHashCode(); hash = hash ^ BirthDate.GetHashCode() ^ Height.GetHashCode(); return(hash); }
private async void calculateAll() { IsProgressBarVisible = true; FieldsEnabled = false; int userAge = await Task.Run(() => _processor.calculateAge(BirthDate)); if (userAge != -1 && _processor.IsValid(Email)) { //TODO exception and isValidAge Age = userAge.ToString(); WesternSign = await Task.Run(() => _processor.calculateSignWest(BirthDate)); EasternSign = await Task.Run(() => _processor.calculateSignEast(BirthDate)); DateBirthDisplay = BirthDate.ToShortDateString(); OnPropertyChanged("Email"); OnPropertyChanged("Name"); OnPropertyChanged("Surname"); if (DateTime.Today.DayOfYear == BirthDate.DayOfYear) { IsBirthday = "Yes"; } else { IsBirthday = "No"; } } IsProgressBarVisible = false; FieldsEnabled = true; }
public override int GetHashCode() { var stringedContact = SecondName + FirstName + ThirdName + Gender.ToString() + BirthDate.ToString() + INN + Address.ToString() + PhoneNumber.ToString() + FullYears + ToString(); return(stringedContact.GetHashCode()); }
private void AddClient() { if (AreFormsFilled()) { CalcAge(); if (_age < 18) { MessageBox.Show(BirthDate.ToString()); return; } using (MySqlCommand comm = ConnectionManager.Connection.CreateCommand()) { comm.CommandText = "INSERT INTO client(pasport_number, surname, name, fathers_name, birth_date, age, email) VALUES(?pasport_number, ?surname, ?name, ?fathers_name, ?birth_date, ?age, ?email)"; comm.Parameters.Add("?pasport_number", MySqlDbType.VarChar).Value = PasportNumber; comm.Parameters.Add("?surname", MySqlDbType.VarChar).Value = Surname; comm.Parameters.Add("?name", MySqlDbType.VarChar).Value = Name; comm.Parameters.Add("?fathers_name", MySqlDbType.VarChar).Value = FathersName; comm.Parameters.Add("?birth_date", MySqlDbType.DateTime).Value = BirthDate; comm.Parameters.Add("?age", MySqlDbType.Int32).Value = _age; comm.Parameters.Add("?email", MySqlDbType.VarChar).Value = Email; comm.ExecuteNonQuery(); AddPhone(); MessageBox.Show("Successful!"); StationManager.DataStorage.AddClient(new Client(GetLastClientCode(), PasportNumber, Surname, Name, FathersName, BirthDate.Value, _age, Email)); } } }
public override int GetHashCode() { int code = 27; code = unchecked ( code ^ EmployeeID.GetHashCode() ^ FirstName.GetHashCode() ^ Title.GetHashCode() ^ TitleOfCourtesy.GetHashCode() ^ BirthDate.GetHashCode() ^ HireDate.GetHashCode() ^ Address.GetHashCode() ^ City.GetHashCode() ^ Region.GetHashCode() ^ PostalCode.GetHashCode() ^ Country.GetHashCode() ^ HomePhone.GetHashCode() ^ Extension.GetHashCode() ^ Photo.GetHashCode() ^ Notes.GetHashCode() ^ ReportsTo.GetHashCode() ^ PhotoPath.GetHashCode() ); return(code); }
public virtual bool IsValid() { if (string.IsNullOrEmpty(FirstName)) { AddError("Nome é obrigatório"); } if (!Documents.Any(x => x.DocumentTypeId == EDocumentType.CPF)) { AddError($"CPF é Obrigatório"); } foreach (var phone in Phones) { if (!phone.ValidateBrazilianNumber()) { AddError($"Número {phone.ToString()} com formato inválido."); } } foreach (var address in Addresses) { if (!address.IsValid()) { AddError(address.Errors.ToArray()); } } if (BirthDate == default(DateTime)) { AddError($"Data de Nascimento inválida. Data Informada:{BirthDate.ToShortDateString()}"); } return(!Errors.Any()); }
public override string ToString() { //var personInfo = string.Format("{0, -15}{1, -15}{2, -10}", LastName, FirstName, BirthDate.ToShortDateString()); var personInfo = $"{Id,-3}{LastName,-15}{FirstName,-15}{BirthDate.ToShortDateString(),-10}, {GetPersonalInfo()}, {ProtectedValue}, {PrivateValue}"; return(personInfo); }
public override string ToString() { return($"Last name: {LastName}\nFirst name: {FirstName}\n" + $"Patronymic: {Patronymic}\nBirthDate: {BirthDate.ToString("d")}\n" + $"EnterDate: {EnterDate.ToString("d")}\nGroup Index: {GroupIndex}\n" + $"Faculty: {Faculty}\nSpecialization: {Specialization}\nPerformance: {Performance}\n"); }
private void Form_Load(object sender, EventArgs e) { tbFirstName.Text = FirstName; tbLastName.Text = LastName; tbBirthDate.Text = BirthDate.ToShortDateString(); // creating awards list foreach (var award in AwardStorage.awardsList) { chbxUserAwardsBox.Items.Add(award.Title); } // checking awards, that user have already if (Awards != null) { foreach (var award in Awards) { for (int i = 0; i < chbxUserAwardsBox.Items.Count; i++) { if (award.Title == chbxUserAwardsBox.Items[i]) // studio swearing at me, but it works :) { chbxUserAwardsBox.SetItemChecked(i, true); } } } } }
private int GetStudentAge() { var today = DateTime.Today; int diff; if (today.CompareTo(BirthDate) > 0) { diff = today.Year - BirthDate.Year; if (BirthDate.Date > today.AddYears(-diff)) { diff--; } return(diff); } else { diff = BirthDate.Year - today.Year; if (today.Date > BirthDate.AddYears(-diff)) { diff--; } return(diff); } }
public override string ToString() { return(Name + "\t" + BirthDate.ToString() + "\t" + Age.ToString() + "\t" + Money.ToString()); }
public void BirthDate30YearsAgo_Succeeds() { var birthDateDT = DateTime.Now - new TimeSpan(30 * 365, 0, 0, 0); var birthDate = new BirthDate(birthDateDT); Assert.AreEqual(birthDateDT, birthDate.Value); }
public void Configure(EntityTypeBuilder <Author> builder) { builder.ToTable("Author").HasKey(k => k.Id); builder.OwnsOne(p => p.Name, p => { p.Property(pp => pp.First).HasColumnName("FirstName").IsRequired().HasMaxLength(50); p.Property(pp => pp.Last).HasColumnName("LastName").IsRequired().HasMaxLength(50); }); builder.Property(p => p.DateOfBirth) .IsRequired() .HasConversion(p => p.Value, p => BirthDate.Create(p).Value); builder.Property(p => p.DateOfDeath) .HasConversion(p => p.Value, p => DeathDate.Create(p).Value); builder.Property(p => p.MainCategory) .IsRequired() .HasMaxLength(50) .HasConversion(p => p.Value, p => MainCategory.Create(p).Value); builder.HasMany(p => p.Books).WithOne(p => p.Author) .OnDelete(DeleteBehavior.Cascade) .Metadata.PrincipalToDependent.SetPropertyAccessMode(PropertyAccessMode.Field); }
public void EqualsOperator_ValuesEqual_True() { var birthDateDT = new BirthDate(DateTime.Now - new TimeSpan(30 * 365, 0, 0, 0)); var birthDateDT2 = new BirthDate(DateTime.Now - new TimeSpan(30 * 365, 0, 0, 0)); Assert.IsTrue(birthDateDT == birthDateDT2); }
public Contact(int id, Name firstName, Name lastName, BirthDate birthDate, IEnumerable <Email> email, IEnumerable <PhoneNumber> phoneNumbers) { if (firstName == null) { throw new ArgumentNullException(nameof(firstName)); } if (lastName == null) { throw new ArgumentNullException(nameof(lastName)); } if (birthDate == null) { throw new ArgumentNullException(nameof(birthDate)); } this.Id = id; this.FirstName = firstName; this.LastName = lastName; this.BirthDate = birthDate; this.Emails = new ReadOnlyCollection <Email>(this.emails); this.PhoneNumbers = new ReadOnlyCollection <PhoneNumber>(this.phoneNumbers); this.InitializeUniqueList(this.emails, email); this.InitializeUniqueList(this.phoneNumbers, phoneNumbers); }
public void Update(Name name, PersonalNumber personalNumber, DateTime birthDate, string image, Gender gender) { if (!Name.Equals(name)) { Name = name; } if (!PersonalNumber.Equals(personalNumber)) { PersonalNumber = personalNumber; } if (!BirthDate.Equals(birthDate)) { BirthDate = birthDate; } if (!Image.Equals(image)) { Image = image; } if (!Gender.Equals(gender)) { Gender = gender; } }
public override string ToString() { string result = ID + "\n" + FirstName + "\n"; result += BirthDate.ToString() + "\n"; return(result); }