64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
namespace Projekt_Calcan_Conze.Models;
|
|
|
|
using Projekt_Calcan_Conze.Models;
|
|
using System.Text;
|
|
|
|
internal class Customer
|
|
{
|
|
public Customer(
|
|
string title,
|
|
string firstName,
|
|
string lastName,
|
|
DateOnly dateOfBirth,
|
|
string? email,
|
|
Address? address,
|
|
List<PhoneNumber> phoneNumbers)
|
|
{
|
|
this.Title = title;
|
|
this.FirstName = firstName;
|
|
this.LastName = lastName;
|
|
this.DateOfBirth = dateOfBirth;
|
|
this.Email = email;
|
|
this.Address = address;
|
|
this.PhoneNumbers = phoneNumbers;
|
|
}
|
|
|
|
public string Title { get; }
|
|
|
|
public string FirstName { get; }
|
|
|
|
public string LastName { get; }
|
|
|
|
public DateOnly DateOfBirth { get; }
|
|
|
|
public string? Email { get; }
|
|
|
|
public Address? Address { get; }
|
|
|
|
public List<PhoneNumber> PhoneNumbers { get; }
|
|
|
|
public override string ToString()
|
|
{
|
|
StringBuilder builder = new();
|
|
|
|
builder.Append($"{this.Title} {this.FirstName} {this.LastName}");
|
|
builder.Append($"{Constants.Separator} {this.DateOfBirth.ToString(Constants.DateOfBirthFormat)}");
|
|
|
|
if (this.Email is not null)
|
|
{
|
|
builder.Append($"{Constants.Separator} {this.Email}");
|
|
}
|
|
|
|
if (this.Address is not null)
|
|
{
|
|
builder.Append($"{Constants.Separator} {this.Address.StreetAndHouseNumber}");
|
|
builder.Append($"{Constants.Separator} {this.Address.PostalCode} {this.Address.City}");
|
|
}
|
|
|
|
foreach (PhoneNumber phoneNumber in this.PhoneNumbers)
|
|
{
|
|
builder.Append($"{Constants.Separator} {phoneNumber.AreaCode} {phoneNumber.Number}");
|
|
}
|
|
return builder.ToString();
|
|
}
|
|
} |