public ValidationFailure ReferencesValidate(Worker worker, ValidationContext <Worker> context) { var genderType = new GenderType().ConvertToCollection().FirstOrDefault(genderTp => genderTp.Value == worker.Gender); if (genderType.IsNull()) { return(new ValidationFailure("Worker", "El tipo de genero no existe")); } var department = _departmentRepository.FindBy(worker.DepartmentId); if (department.IsNull() || department.Status.Equals(GlobalConstants.StatusDeactivated)) { return(new ValidationFailure("Worker", "El departamento esta desactivado o no existe")); } var job = _jobRepository.FindBy(worker.JobId); if (job.IsNull() || job.Status.Equals(GlobalConstants.StatusDeactivated)) { return(new ValidationFailure("Worker", "El puesto esta desactivado o no existe")); } var role = _roleRepository.FindBy(worker.RoleId); if (role.IsNull() || role.Status.Equals(GlobalConstants.StatusDeactivated)) { return(new ValidationFailure("Worker", "El rol esta desactivado o no existe")); } var branch = _branchRepository.FindBy(worker.BranchId); if (branch.IsNull() || branch.Status.Equals(GlobalConstants.StatusDeactivated)) { return(new ValidationFailure("Worker", "La sucursal esta desactivada o no existe")); } return(null); }