Esempio n. 1
0
        public string IsValidEmployee(EmployeeDataContext instanceDataModel)
        {
            if (instanceDataModel != null)
            {
                if (instanceDataModel.language == null || instanceDataModel.language == " ")
                {
                    return(Messages.LANG_ERROR);
                }
                else if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_AR) == true)
                {
                    if (ValedationClass.IsValidNameAr(instanceDataModel.employeeName) == false)
                    {
                        return(Messages.NAME_AR_ERROR);
                    }
                    if (instanceDataModel.employeeAddress != null)
                    {
                        if (ValedationClass.IsValidTextAr(instanceDataModel.employeeAddress) == false)
                        {
                            return(Messages.ADRESS_AR_ERROR);
                        }
                    }

                    if (ValedationClass.IsValidPhone(instanceDataModel.employeePhone, instanceDataModel.employeeCountryCode, instanceDataModel.employeeCCName) == false)
                    {
                        return(Messages.PHONE_AR_ERROR);
                    }

                    return(true.ToString());
                }
                else if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                {
                    if (ValedationClass.IsValidNameEn(instanceDataModel.employeeName) == false)
                    {
                        return(Messages.NAME_EN_ERROR);
                    }
                    if (instanceDataModel.employeeAddress != null)
                    {
                        if (ValedationClass.IsValidTextEn(instanceDataModel.employeeAddress) == false)
                        {
                            return(Messages.ADRESS_EN_ERROR);
                        }
                    }

                    if (ValedationClass.IsValidPhone(instanceDataModel.employeePhone, instanceDataModel.employeeCountryCode, instanceDataModel.employeeCCName) == false)
                    {
                        return(Messages.PHONE_EN_ERROR);
                    }

                    return(true.ToString());
                }
                else
                {
                    return(Messages.LANG_ERROR);
                }
            }
            else
            {
                return(Messages.LIST_ERROR);
            }
        }
        public string IsValidEmployee(EmployeeDataContext instanceDataModel)
        {
            if (instanceDataModel != null)
            {
                if (instanceDataModel.language == null || instanceDataModel.language == " ")
                {
                    return(Messages.LANG_ERROR);
                }
                else if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_AR) == true)
                {
                    if (ValedationClass.IsValidNameAr(instanceDataModel.employeeName) == false)
                    {
                        return(Messages.NAME_AR_ERROR);
                    }

                    //employeeNationality
                    if (instanceDataModel.employeeNationality != null)
                    {
                        if (ValedationClass.IsValidTextAr(instanceDataModel.employeeNationality) == false)
                        {
                            return(Messages.NATIONALITY_AR_ERROR);
                        }
                    }

                    //FIRST PHONE
                    if (ValedationClass.IsValidPhone(instanceDataModel.employeeFirstPhone, instanceDataModel.employeeFirstCountryCode, instanceDataModel.employeeFirstCountryCodeName) == false)
                    {
                        return(Messages.PHONE_AR_ERROR);
                    }

                    //SECOND PHONE
                    if (instanceDataModel.employeeSecondPhone != null)
                    {
                        if (ValedationClass.IsValidPhone(instanceDataModel.employeeSecondPhone, instanceDataModel.employeeSecondCountryCode, instanceDataModel.employeeSecondCountryCodeName) == false)
                        {
                            return(Messages.PHONE_AR_ERROR);
                        }
                    }

                    if (instanceDataModel.employeeImagePath != null)
                    {
                        if (ValedationClass.IsValidImage(instanceDataModel.employeeImagePath) == false)
                        {
                            return(Messages.IMG_AR_ERROR);
                        }
                    }

                    if (instanceDataModel.employeeBirthDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeBirthDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.DATE_AR_ERROR);
                        }
                    }
                    //employeeEmail
                    if (instanceDataModel.employeeEmail != null)
                    {
                        if (ValedationClass.IsValidEmail(instanceDataModel.employeeEmail) == false)
                        {
                            return(Messages.EMAIL_AR_ERROR);
                        }
                    }

                    //employeeCardBankNumber
                    if (instanceDataModel.employeeCardBankNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeCardBankNumber) == false || instanceDataModel.employeeCardBankNumber.Length > 24)
                        {
                            return(Messages.BANK_CARD_AR_ERROR);
                        }
                    }
                    //employeeGender    here
                    if (instanceDataModel.employeeGender != null)
                    {
                        if (instanceDataModel.employeeGender == "1")
                        {
                            instanceDataModel.employeeGender = Constants.male_AR;
                            if (ValedationClass.IsValidGender(instanceDataModel.employeeGender) == false)
                            {
                                return(Messages.GENDER_AR_ERROR);
                            }
                        }
                        else if (instanceDataModel.employeeGender == "2")
                        {
                            instanceDataModel.employeeGender = Constants.female_AR;
                            if (ValedationClass.IsValidGender(instanceDataModel.employeeGender) == false)
                            {
                                return(Messages.GENDER_AR_ERROR);
                            }
                        }
                        else
                        {
                            return(Messages.GENDER_AR_ERROR);
                        }
                    }
                    //employeeMaritalStatus
                    if (instanceDataModel.employeeMaritalStatus != null)
                    {
                        if (instanceDataModel.employeeMaritalStatus == "1")
                        {
                            instanceDataModel.employeeMaritalStatus = Constants.SINGLE_AR;
                        }
                        else if (instanceDataModel.employeeMaritalStatus == "2")
                        {
                            instanceDataModel.employeeMaritalStatus = Constants.MARID_AR;
                        }
                        else
                        {
                            return(Messages.Marital_AR_ERROR);
                        }
                    }

                    //employeeMilitaryStatus
                    if (instanceDataModel.employeeMilitaryStatus != null)
                    {
                        if (instanceDataModel.employeeMilitaryStatus == "1")
                        {
                            instanceDataModel.employeeMilitaryStatus = Constants.MILITARY_COMPLETED_AR;
                        }
                        else if (instanceDataModel.employeeMilitaryStatus == "2")
                        {
                            instanceDataModel.employeeMilitaryStatus = Constants.MILITARY_UNCOMPLETED_AR;
                        }
                        else if (instanceDataModel.employeeMilitaryStatus == "3")
                        {
                            instanceDataModel.employeeMilitaryStatus = Constants.MILITARY_MOAFA_AR;
                        }
                        else
                        {
                            return(Messages.MILITARY_AR_ERROR);
                        }
                    }
                    //employeeLicenseNumber
                    if (instanceDataModel.employeeLicenseNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeLicenseNumber) == false || instanceDataModel.employeeLicenseNumber.Length > 24)
                        {
                            return(Messages.LICENCE_AR_ERROR);
                        }
                    }
                    //employeeLicenseExpireDate
                    if (instanceDataModel.employeeLicenseExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeLicenseExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.LICENCE_DATE_AR_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeLicenseExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_AR_ERROR);
                        }
                    }

                    //employeeIdentityNumber
                    if (instanceDataModel.employeeIdentityNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeIdentityNumber) == false || instanceDataModel.employeeIdentityNumber.Length > 24)
                        {
                            return(Messages.IDENTITY_AR_ERROR);
                        }
                    }
                    //employeeIdentityExpireDate
                    if (instanceDataModel.employeeIdentityExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeIdentityExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.IDENTITY_DATE_AR_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeIdentityExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_AR_ERROR);
                        }
                    }
                    //employeePassportNumber
                    if (instanceDataModel.employeePassportNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeePassportNumber) == false || instanceDataModel.employeePassportNumber.Length > 24)
                        {
                            return(Messages.PASSPORT_AR_ERROR);
                        }
                    }
                    //employeePassportExpireDate
                    if (instanceDataModel.employeePassportExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeePassportExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.PASSPORT_DATE_AR_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeePassportExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_AR_ERROR);
                        }
                    }
                    //employeeContractStartDate
                    if (instanceDataModel.employeeContractStartDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeContractStartDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.CONTRACT_DATE_AR_ERROR);
                        }
                    }
                    //employeeContractEndDate
                    if (instanceDataModel.employeeContractEndDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeContractEndDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.CONTRACT_DATE_AR_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeContractEndDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_AR_ERROR);
                        }
                    }
                    //employeeResidenceNumber
                    if (instanceDataModel.employeeResidenceNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeResidenceNumber) == false || instanceDataModel.employeeResidenceNumber.Length > 24)
                        {
                            return(Messages.RESEDENCE_AR_ERROR);
                        }
                    }
                    //employeeResidenceExpireDate
                    if (instanceDataModel.employeeResidenceExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeResidenceExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.RESEDENCE_DATE_AR_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeResidenceExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_AR_ERROR);
                        }
                    }
                    //employeeInsuranceNumber
                    if (instanceDataModel.employeeInsuranceNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeInsuranceNumber) == false || instanceDataModel.employeeInsuranceNumber.Length > 24)
                        {
                            return(Messages.INSURANCE_AR_ERROR);
                        }
                    }
                    //employeeAdressDetails
                    if (instanceDataModel.employeeAdressDetails != null)
                    {
                        if (ValedationClass.IsValidTextAr(instanceDataModel.employeeAdressDetails) == false)
                        {
                            return(Messages.ADRESS_AR_ERROR);
                        }
                    }

                    return(true.ToString());
                }
                else if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                {
                    if (ValedationClass.IsValidNameEn(instanceDataModel.employeeName) == false)
                    {
                        return(Messages.NAME_EN_ERROR);
                    }

                    if (instanceDataModel.employeeAdressDetails != null)
                    {
                        if (ValedationClass.IsValidTextEn(instanceDataModel.employeeAdressDetails) == false)
                        {
                            return(Messages.ADRESS_EN_ERROR);
                        }
                    }

                    if (ValedationClass.IsValidPhone(instanceDataModel.employeeFirstPhone, instanceDataModel.employeeFirstCountryCode, instanceDataModel.employeeFirstCountryCodeName) == false)
                    {
                        return(Messages.PHONE_EN_ERROR);
                    }

                    //SECOND PHONE
                    if (instanceDataModel.employeeSecondPhone != null)
                    {
                        if (ValedationClass.IsValidPhone(instanceDataModel.employeeSecondPhone, instanceDataModel.employeeSecondCountryCode, instanceDataModel.employeeSecondCountryCodeName) == false)
                        {
                            return(Messages.PHONE_EN_ERROR);
                        }
                    }

                    if (instanceDataModel.employeeImagePath != null)
                    {
                        if (ValedationClass.IsValidImage(instanceDataModel.employeeImagePath) == false)
                        {
                            return(Messages.IMG_EN_ERROR);
                        }
                    }

                    //employeeNationality
                    if (instanceDataModel.employeeNationality != null)
                    {
                        if (ValedationClass.IsValidTextEn(instanceDataModel.employeeNationality) == false)
                        {
                            return(Messages.NATIONALITY_EN_ERROR);
                        }
                    }

                    //----------------------------------------------------------------------------

                    if (instanceDataModel.employeeBirthDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeBirthDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.DATE_EN_ERROR);
                        }
                    }
                    //employeeEmail
                    if (instanceDataModel.employeeEmail != null)
                    {
                        if (ValedationClass.IsValidEmail(instanceDataModel.employeeEmail) == false)
                        {
                            return(Messages.EMAIL_EN_ERROR);
                        }
                    }

                    //employeeCardBankNumber
                    if (instanceDataModel.employeeCardBankNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeCardBankNumber) == false || instanceDataModel.employeeCardBankNumber.Length > 24)
                        {
                            return(Messages.BANK_CARD_EN_ERROR);
                        }
                    }
                    //employeeGender    here
                    if (instanceDataModel.employeeGender != null)
                    {
                        if (instanceDataModel.employeeGender == "1")
                        {
                            instanceDataModel.employeeGender = Constants.male_AR;
                            if (ValedationClass.IsValidGender(instanceDataModel.employeeGender) == false)
                            {
                                return(Messages.GENDER_EN_ERROR);
                            }
                        }
                        else if (instanceDataModel.employeeGender == "2")
                        {
                            instanceDataModel.employeeGender = Constants.female_AR;
                            if (ValedationClass.IsValidGender(instanceDataModel.employeeGender) == false)
                            {
                                return(Messages.GENDER_EN_ERROR);
                            }
                        }
                        else
                        {
                            return(Messages.GENDER_EN_ERROR);
                        }
                    }
                    //employeeMaritalStatus
                    if (instanceDataModel.employeeMaritalStatus != null)
                    {
                        if (instanceDataModel.employeeMaritalStatus == "1")
                        {
                            instanceDataModel.employeeMaritalStatus = Constants.SINGLE_EN;
                        }
                        else if (instanceDataModel.employeeMaritalStatus == "2")
                        {
                            instanceDataModel.employeeMaritalStatus = Constants.MARID_EN;
                        }
                        else
                        {
                            return(Messages.Marital_EN_ERROR);
                        }
                    }

                    //employeeMilitaryStatus
                    if (instanceDataModel.employeeMilitaryStatus != null)
                    {
                        if (instanceDataModel.employeeMilitaryStatus == "1")
                        {
                            instanceDataModel.employeeMilitaryStatus = Constants.MILITARY_COMPLETED_EN;
                        }
                        else if (instanceDataModel.employeeMilitaryStatus == "2")
                        {
                            instanceDataModel.employeeMilitaryStatus = Constants.MILITARY_UNCOMPLETED_EN;
                        }
                        else if (instanceDataModel.employeeMilitaryStatus == "3")
                        {
                            instanceDataModel.employeeMilitaryStatus = Constants.MILITARY_MOAFA_EN;
                        }
                        else
                        {
                            return(Messages.MILITARY_EN_ERROR);
                        }
                    }
                    //employeeLicenseNumber
                    if (instanceDataModel.employeeLicenseNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeLicenseNumber) == false || instanceDataModel.employeeLicenseNumber.Length > 24)
                        {
                            return(Messages.LICENCE_EN_ERROR);
                        }
                    }
                    //employeeLicenseExpireDate
                    if (instanceDataModel.employeeLicenseExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeLicenseExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.LICENCE_DATE_EN_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeLicenseExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_EN_ERROR);
                        }
                    }

                    //employeeIdentityNumber
                    if (instanceDataModel.employeeIdentityNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeIdentityNumber) == false || instanceDataModel.employeeIdentityNumber.Length > 24)
                        {
                            return(Messages.IDENTITY_EN_ERROR);
                        }
                    }
                    //employeeIdentityExpireDate
                    if (instanceDataModel.employeeIdentityExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeIdentityExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.IDENTITY_DATE_EN_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeIdentityExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_EN_ERROR);
                        }
                    }
                    //employeePassportNumber
                    if (instanceDataModel.employeePassportNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeePassportNumber) == false || instanceDataModel.employeePassportNumber.Length > 24)
                        {
                            return(Messages.PASSPORT_EN_ERROR);
                        }
                    }
                    //employeePassportExpireDate
                    if (instanceDataModel.employeePassportExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeePassportExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.PASSPORT_DATE_EN_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeePassportExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_EN_ERROR);
                        }
                    }
                    //employeeContractStartDate
                    if (instanceDataModel.employeeContractStartDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeContractStartDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.CONTRACT_DATE_EN_ERROR);
                        }
                    }
                    //employeeContractEndDate
                    if (instanceDataModel.employeeContractEndDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeContractEndDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.CONTRACT_DATE_EN_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeContractEndDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_EN_ERROR);
                        }
                    }
                    //employeeResidenceNumber
                    if (instanceDataModel.employeeResidenceNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeResidenceNumber) == false || instanceDataModel.employeeResidenceNumber.Length > 24)
                        {
                            return(Messages.RESEDENCE_EN_ERROR);
                        }
                    }
                    //employeeResidenceExpireDate
                    if (instanceDataModel.employeeResidenceExpireDate != null)
                    {
                        if (ValedationClass.IsValiDateTime(instanceDataModel.employeeResidenceExpireDate, ConstansValuesClass.formatDate) == false)
                        {
                            return(Messages.RESEDENCE_DATE_EN_ERROR);
                        }

                        if (Convert.ToDateTime(instanceDataModel.employeeResidenceExpireDate) < Convert.ToDateTime(MethodesClass.DateNow()))
                        {
                            return(Messages.DATENow_EN_ERROR);
                        }
                    }
                    //employeeInsuranceNumber
                    if (instanceDataModel.employeeInsuranceNumber != null)
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.employeeInsuranceNumber) == false || instanceDataModel.employeeInsuranceNumber.Length > 24)
                        {
                            return(Messages.INSURANCE_EN_ERROR);
                        }
                    }
                    //------------------------------------------------------------------------------


                    return(true.ToString());
                }
                else
                {
                    return(Messages.LANG_ERROR);
                }
            }
            else
            {
                return(Messages.LIST_ERROR);
            }
        }