示例#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;
 }