} //per month //public double profit { get; set; } //public DateTime leaving { get; set; }//If the employee left before the final date. //public Enums.Cars car { get; set; } public override string ToString() { string str = "Contract number: " + number.ToString() + "\n"; str += "Employer Id: " + EmployerId.ToString() + "\n"; str += "Employee Id " + EmployeeId.ToString() + "\n"; str += "Interview: "; if (interview == true) { str += "Yes,"; } else { str += "No,"; } str += "\nSigned: "; if (signed == true) { str += "Yes,"; } else { str += "No,"; } str += "\nNeto salary: " + netoSalary.ToString() + "\n"; str += "Beggining date of work: " + beginning.ToShortDateString() + "\n"; str += "Final date of work: " + final.ToShortDateString() + "\n"; return(str); }
public Employee(EmployerId id /* other params such as name etc */) { var employerSetResult = this.SetEmployerId(id); if (!result.Success) { throw new ArgumentException("id", "id is invalid"); } }
private Result SetEmployerId(Employer id) { var result = EmployerIdValidator.Validate(id); if (result.Success) { this.employerId = id; } return(result); }
public Result ChangeEmployer(EmployerId id) { var result = EmployerIdValidator.Validate(id); if (result.Success) { this.employerId = id; } return(result); }
// this is a separate method because you will need to set employerId // from multiple locations and should only ever call SetEmployerId // internally public Result ChangeEmployer(EmployerId id) { var result = this.SetEmployerId(id); if (result.Success) { DomainEventPublisher.Publish( new EmployeeEmployerChanged(id, this.id)); } return(result); }
public static Result Validate(EmployerId id) { if (id < 5) { return(new Result(success: false, new ValidationResult("Id too low"))); } else if (id > 10) { return(new Result(success: false, new ValidationResult("Id too high"))); } return(new Result(success: true)); }
// this is a separate method because you will need to set employerId // from multiple locations and should only ever call SetEmployerId // internally public Result ChangeEmployer(EmployerId id) { return(this.SetEmployerId(id)); }