public void Validate()
        {
            new AddNotifications <FuncionarioEntity>(this)
            .IfLowerOrEqualsThan(Id, 0, "Id must be greater than zero")
            .IfNullOrEmpty(Name, "Name is obligatory")
            .IfNullOrEmpty(Gender, "Gender is obligatory")
            .IfNullOrEmpty(BirthDay.ToString(), "BirthDay is obligatory")
            .IfNullOrEmpty(Salary.ToString(), "Salary is obligatory")
            .IfNullOrEmpty(Level, "Level is obligatory")
            .IfNullOrEmpty(HiringDate.ToString(), "HiringDate is obligatory")
            .IfLengthGreaterThan(Name, 64, "Name must be a maximum of 64 characters")
            .IfLengthGreaterThan(Gender, 1, "Gender must be a maximum of 1 characters")
            .IfGreaterOrEqualsThan(BirthDay, DateTime.Now, "BirthDay must be smaller than today")
            .IfLowerOrEqualsThan(Salary, 800, "Salary must be greater than R$ 800,00")
            .IfLengthGreaterThan(Level, 1, "Level must be a maximum of 1 characters")
            .IfGreaterThan(HiringDate, DateTime.Now, "HiringDate must be less than or equals today");

            if (!new string[] { "F", "M" }.Contains(Gender))
            {
                AddNotification("Gender", "Gender should be M or F");
            }

            if (!new string[] { "J", "P", "S" }.Contains(Level))
            {
                AddNotification("Level", "Level should be J, P or S");
            }
        }
Ejemplo n.º 2
0
 public void PrintInfo()
 {
     Console.WriteLine("Name: " + FirstName + " " + LastName
                       + ", Position: " + Position
                       + ", Cabinet: " + Cabinet
                       + ", Hiring Date: " + HiringDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)
                       + ", " + string.Format("Salary: {0:C2}", Salary, CultureInfo.InvariantCulture));
 }