コード例 #1
0
ファイル: Contract.cs プロジェクト: elisheva100/DotNetProject
        }                                     //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);
        }
コード例 #2
0
    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");
        }
    }
コード例 #3
0
    private Result SetEmployerId(Employer id)
    {
        var result = EmployerIdValidator.Validate(id);

        if (result.Success)
        {
            this.employerId = id;
        }
        return(result);
    }
コード例 #4
0
    public Result ChangeEmployer(EmployerId id)
    {
        var result = EmployerIdValidator.Validate(id);

        if (result.Success)
        {
            this.employerId = id;
        }
        return(result);
    }
コード例 #5
0
    // 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);
    }
コード例 #6
0
 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));
 }
コード例 #7
0
 // 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));
 }