Skip to content

Instantly share code, notes, and snippets.

@maiconheck
Last active June 23, 2023 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maiconheck/865369bc5ec7faf1e611838c099db909 to your computer and use it in GitHub Desktop.
Save maiconheck/865369bc5ec7faf1e611838c099db909 to your computer and use it in GitHub Desktop.
[4º Improvement]
public class Lead : Entity
{
private readonly List<Segment> _segments;
public Lead(Name name, Email email)
{
Guard.Against
.Null(name, nameof(name))
.Null(email, nameof(email));
_segments = new List<Segment>();
Name = name;
Email = email;
}
public Name Name { get; }
public Email Email { get; }
public PhoneNumber? PhoneNumber { get; private set; }
public Address? Address { get; private set; }
public bool? Gender { get; private set; }
public DateTime? BirthDate { get; private set; }
public IReadOnlyList<Segment> Segments => _segments.ToList();
public void AddSegment(Segment segment)
{
Guard.Against.Null(segment, nameof(segment));
_segments.Add(segment);
}
public void CompleteInfo(PhoneNumber phoneNumber, Address address, bool gender, DateTime birthDate)
{
Guard.Against
.Null(phoneNumber, nameof(phoneNumber))
.Null(address, nameof(address));
PhoneNumber = phoneNumber;
Address = address;
Gender = gender;
BirthDate = birthDate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment