예제 #1
0
 public virtual void PromoteTo(EmploymentRole role)
 {
     EmploymentRole = role;
     DomainEvents.Add(new EmployeeWasPromotedEvent {
         Employee = this
     });
 }
예제 #2
0
        public static Result <Employee> Create(string firstName, string lastName, EmploymentRole role)
        {
            var name = EmployeeName.Create(firstName, lastName);

            if (name.IsFailure)
            {
                return(Result.Fail <Employee>(name.Error));
            }

            if (role == null)
            {
                return(Result.Fail <Employee>("EmploymentRole cannot be null"));
            }

            return(Result.Ok(new Employee(name.Value, role)));
        }
예제 #3
0
 private Employee(EmployeeName name, EmploymentRole role) : this()
 {
     Name           = name;
     EmploymentRole = role;
 }