示例#1
0
        // Translation Method
        public void Translation(EmployeeDataContext instanceDataModel)
        {
            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_AR) == true)
            {
                instanceDataModel.employNameEN    = TranslatorGoogleClass.Translate(instanceDataModel.employeeName, Constants.LAN_AR, Constants.LAN_EN);
                instanceDataModel.employeeNameAR  = instanceDataModel.employeeName;
                instanceDataModel.employeePhoneCC = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeePhone, instanceDataModel.employeeCCName);

                if (instanceDataModel.employeeAddress != null)
                {
                    instanceDataModel.employeeAddressEN = TranslatorGoogleClass.Translate(instanceDataModel.employeeAddress, Constants.LAN_AR, Constants.LAN_EN);
                    instanceDataModel.employeeAddressAR = instanceDataModel.employeeAddress;
                    instanceDataModel.employeePhoneCC   = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeePhone, instanceDataModel.employeeCCName);
                }
            }
            else
            {
                instanceDataModel.employeeNameAR  = TranslatorGoogleClass.Translate(instanceDataModel.employeeName, Constants.LAN_EN, Constants.LAN_AR);
                instanceDataModel.employNameEN    = instanceDataModel.employeeName;
                instanceDataModel.employeePhoneCC = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeePhone, instanceDataModel.employeeCCName);

                if (instanceDataModel.employeeAddress != null)
                {
                    instanceDataModel.employeeAddressAR = TranslatorGoogleClass.Translate(instanceDataModel.employeeAddress, Constants.LAN_EN, Constants.LAN_AR);
                    instanceDataModel.employeeAddressEN = instanceDataModel.employeeAddress;
                    instanceDataModel.employeePhoneCC   = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeePhone, instanceDataModel.employeeCCName);
                }
            }
        }
示例#2
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);
            }
        }
示例#3
0
        public HttpResponseMessage DeleteEmployee([FromBody] EmployeeDataContext instanceDataModel)
        {
            try
            {
                if (instanceDataModel == null || instanceDataModel.language == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPLOYEE_NULL_ERROR, data = Messages.EMPTY }));
                }

                EmployeeData dtEmployee = employeeDB.GetEmployeeById(instanceDataModel.employeeId);
                if (dtEmployee != null)
                {
                    int isDelete = employeeDB.DeleteEmployee(instanceDataModel.employeeId);
                    if (isDelete > 0)
                    {
                        if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = Messages.EMPTY }));
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = Messages.EMPTY }));
                        }
                    }
                    else
                    {
                        if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.DELETE_EN_ERROR, data = Messages.EMPTY }));
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.DELETE_ERROR, data = Messages.EMPTY }));
                        }
                    }
                }
                else
                {
                    if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EN_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                    }
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EMPLOYEE_ERROR, data = Messages.EMPTY }));
            }
        }
示例#4
0
        public EmployeeData GetEmployee(string textSearch, string lang)
        {
            EmployeeData employeeData;
            DataTable    dtEmployee;
            string       queryString;

            if (ValedationClass.IsValidCompareToStrings(lang.ToString(), Constants.LAN_EN) == true)
            {
                queryString  = Constants.SelectEnQuery + " where[employeeNameAR] = N'" + textSearch + "' or[employeePhone] = N'" + textSearch + "' or[employNameEN] = N'" + textSearch + "'";
                dtEmployee   = GetanythingThroughQuery(queryString);
                employeeData = CustEnEmployee(dtEmployee, 0);
                return(employeeData);
            }

            queryString  = Constants.SelectArQuery + " where[employeeNameAR] = N'" + textSearch + "' or[employeePhone] = N'" + textSearch + "' or[employNameEN] = N'" + textSearch + "'";
            dtEmployee   = GetanythingThroughQuery(queryString);
            employeeData = CustArEmployee(dtEmployee, 0);
            return(employeeData);
        }
示例#5
0
        public List <EmployeeData> GetAllEmployee(string lang)
        {
            List <EmployeeData> EmployeesData;
            DataTable           dtEmployees;

            if (ValedationClass.IsValidCompareToStrings(lang.ToString(), Constants.LAN_EN) == true)
            {
                dtEmployees   = GetanythingThroughQuery(Constants.SelectEnQuery);
                EmployeesData = CustEnEmployeesData(dtEmployees);
                foreach (var item in EmployeesData)
                {
                    return(EmployeesData);
                }
            }

            dtEmployees   = GetanythingThroughQuery(Constants.SelectArQuery);
            EmployeesData = CustArEmployeesData(dtEmployees);
            return(EmployeesData);
        }
示例#6
0
        public EmployeeData SearchByNameEmployee(EmployeeDataContext instanceDataModel)
        {
            EmployeeData employeeData;
            string       queryUpdate;

            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
            {
                queryUpdate = Constants.SelectQuery
                              + " WHERE [employNameEN] = N'" + instanceDataModel.employeeName.Trim() + "'";
            }
            else
            {
                queryUpdate = Constants.SelectQuery
                              + " WHERE [employeeNameAR] = N'" + instanceDataModel.employeeName.Trim() + "'";
            }
            DataTable dtEmployee = GetanythingThroughQuery(queryUpdate);

            employeeData = CustOneEmployee(dtEmployee, 0);
            return(employeeData);
        }
示例#7
0
        public HttpResponseMessage GetAllEmployee([FromUri] EmployeeDataContext instanceDataModel)
        {
            List <EmployeeData> dtEmployees;

            try
            {
                if (instanceDataModel == null || instanceDataModel.language == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPLOYEE_NULL_ERROR, data = Messages.EMPTY }));
                }

                dtEmployees = employeeDB.GetAllEmployee(instanceDataModel.language);

                if (dtEmployees.Count > 0)
                {
                    if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = dtEmployees }));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = dtEmployees }));
                    }
                }
                else
                {
                    if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.GETALL_EMPLOYEE_EN_ERROR, data = Messages.EMPTY }));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.GETALL_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                    }
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.GETALL_EMPLOYEE_ERROR, data = Messages.EMPTY }));
            }
        }
示例#8
0
        public List <EmployeeData> GetAllEmployee(EmployeeDataContext paging)
        {
            List <EmployeeData> EmployeesData;
            DataTable           dtEmployees;
            string queryString;
            int    PagNum  = MethodesConvertalClass.ConvertToInt(paging.pageNumber);
            int    PagSize = MethodesConvertalClass.ConvertToInt(paging.pageSize);

            if (ValedationClass.IsValidCompareToStrings(paging.language.ToString(), Constants.LAN_EN) == true)
            {
                queryString   = Constants.SelectEnQuery + "ORDER BY [employeeId] OFFSET " + (PagNum - 1) * PagSize + " ROWS FETCH NEXT " + PagSize + " ROWS ONLY";
                dtEmployees   = GetanythingThroughQuery(queryString);
                EmployeesData = EmployeeCasting.CustEnEmployeesData(dtEmployees);
                return(EmployeesData);
            }

            queryString   = Constants.SelectArQuery + "ORDER BY [employeeId] OFFSET " + (PagNum - 1) * PagSize + " ROWS FETCH NEXT " + PagSize + " ROWS ONLY";
            dtEmployees   = GetanythingThroughQuery(queryString);
            EmployeesData = EmployeeCasting.CustArEmployeesData(dtEmployees);
            return(EmployeesData);
        }
        public void Translation(EmployeeDataContext instanceDataModel)
        {
            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_AR) == true)
            {
                instanceDataModel.employeeNameEN = TranslatorGoogleClass.Translate(instanceDataModel.employeeName, Constants.LAN_AR, Constants.LAN_EN);
                instanceDataModel.employeeNameAR = instanceDataModel.employeeName;

                if (instanceDataModel.employeeNationality != null)
                {
                    instanceDataModel.employeeNationalityEN = TranslatorGoogleClass.Translate(instanceDataModel.employeeNationality, Constants.LAN_AR, Constants.LAN_EN);
                    instanceDataModel.employeeNationalityAR = instanceDataModel.employeeNationality;
                }
                else
                {
                    instanceDataModel.employeeNationalityEN = " ";
                    instanceDataModel.employeeNationalityAR = " ";
                }

                if (instanceDataModel.employeeMaritalStatus != null)
                {
                    instanceDataModel.employeeMaritalStatusEN = TranslatorGoogleClass.Translate(instanceDataModel.employeeMaritalStatus, Constants.LAN_AR, Constants.LAN_EN);
                    instanceDataModel.employeeMaritalStatusAR = instanceDataModel.employeeMaritalStatus;
                }
                else
                {
                    instanceDataModel.employeeMaritalStatusEN = " ";
                    instanceDataModel.employeeMaritalStatusAR = " ";
                }


                if (instanceDataModel.employeeMilitaryStatus != null)
                {
                    instanceDataModel.employeeMilitaryStatusEN = TranslatorGoogleClass.Translate(instanceDataModel.employeeMilitaryStatus, Constants.LAN_AR, Constants.LAN_EN);
                    instanceDataModel.employeeMilitaryStatusAR = instanceDataModel.employeeMilitaryStatus;
                }
                else
                {
                    instanceDataModel.employeeMilitaryStatusEN = " ";
                    instanceDataModel.employeeMilitaryStatusAR = " ";
                }

                instanceDataModel.employeeFirstPhoneWithCC = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeeFirstPhone, instanceDataModel.employeeFirstCountryCodeName);

                if (instanceDataModel.employeeSecondPhone != null)
                {
                    instanceDataModel.employeeSecondPhoneWithCC = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeeSecondPhone, instanceDataModel.employeeSecondCountryCodeName);
                }
                else
                {
                    instanceDataModel.employeeSecondPhoneWithCC     = " ";
                    instanceDataModel.employeeSecondCountryCode     = " ";
                    instanceDataModel.employeeSecondCountryCodeName = " ";
                    instanceDataModel.employeeSecondPhone           = " ";
                }

                if (instanceDataModel.employeeAdressDetails != null)
                {
                    instanceDataModel.employeeAdressDetailsEN = TranslatorGoogleClass.Translate(instanceDataModel.employeeAdressDetails, Constants.LAN_AR, Constants.LAN_EN);
                    instanceDataModel.employeeAdressDetailsAR = instanceDataModel.employeeAdressDetails;
                }
                else
                {
                    instanceDataModel.employeeAdressDetailsEN = " ";
                    instanceDataModel.employeeAdressDetailsAR = " ";
                }
            }
            else
            {
                instanceDataModel.employeeNameAR = TranslatorGoogleClass.Translate(instanceDataModel.employeeName, Constants.LAN_EN, Constants.LAN_AR);
                instanceDataModel.employeeNameEN = instanceDataModel.employeeName;

                if (instanceDataModel.employeeNationality != null)
                {
                    instanceDataModel.employeeNationalityAR = TranslatorGoogleClass.Translate(instanceDataModel.employeeNationality, Constants.LAN_EN, Constants.LAN_AR);
                    instanceDataModel.employeeNationalityEN = instanceDataModel.employeeNationality;
                }
                else
                {
                    instanceDataModel.employeeNationalityEN = " ";
                    instanceDataModel.employeeNationalityAR = " ";
                }

                if (instanceDataModel.employeeMaritalStatus != null)
                {
                    instanceDataModel.employeeMaritalStatusAR = TranslatorGoogleClass.Translate(instanceDataModel.employeeMaritalStatus, Constants.LAN_EN, Constants.LAN_AR);
                    instanceDataModel.employeeMaritalStatusEN = instanceDataModel.employeeMaritalStatus;
                }
                else
                {
                    instanceDataModel.employeeMaritalStatusEN = " ";
                    instanceDataModel.employeeMaritalStatusAR = " ";
                }


                if (instanceDataModel.employeeMilitaryStatus != null)
                {
                    instanceDataModel.employeeMilitaryStatusAR = TranslatorGoogleClass.Translate(instanceDataModel.employeeMilitaryStatus, Constants.LAN_EN, Constants.LAN_AR);
                    instanceDataModel.employeeMilitaryStatusEN = instanceDataModel.employeeMilitaryStatus;
                }
                else
                {
                    instanceDataModel.employeeMilitaryStatusEN = " ";
                    instanceDataModel.employeeMilitaryStatusAR = " ";
                }

                instanceDataModel.employeeFirstPhoneWithCC = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeeFirstPhone, instanceDataModel.employeeFirstCountryCodeName);

                if (instanceDataModel.employeeSecondPhone != null)
                {
                    instanceDataModel.employeeSecondPhoneWithCC = MethodesClass.ConcatonatePhoneWithCc(instanceDataModel.employeeSecondPhone, instanceDataModel.employeeSecondCountryCodeName);
                }
                else
                {
                    instanceDataModel.employeeSecondPhoneWithCC     = " ";
                    instanceDataModel.employeeSecondCountryCode     = " ";
                    instanceDataModel.employeeSecondCountryCodeName = " ";
                    instanceDataModel.employeeSecondPhone           = " ";
                }

                if (instanceDataModel.employeeAdressDetails != null)
                {
                    instanceDataModel.employeeAdressDetailsAR = TranslatorGoogleClass.Translate(instanceDataModel.employeeAdressDetails, Constants.LAN_EN, Constants.LAN_AR);
                    instanceDataModel.employeeAdressDetailsEN = instanceDataModel.employeeAdressDetails;
                }
                else
                {
                    instanceDataModel.employeeAdressDetailsEN = " ";
                    instanceDataModel.employeeAdressDetailsAR = " ";
                }
            }
        }
        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);
            }
        }
示例#11
0
        public HttpResponseMessage AddEmployee([FromBody] EmployeeDataContext instanceDataModel)
        {
            try
            {
                if (instanceDataModel == null || instanceDataModel.language == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPLOYEE_NULL_ERROR, data = Messages.EMPTY }));
                }

                string isValid = employeeValid.IsValidEmployee(instanceDataModel);
                if (ValedationClass.IsValidCompareToStrings(isValid, true.ToString()) == true)
                {
                    EmployeeData isDubleName = employeeDB.SearchByNameEmployee(instanceDataModel);
                    if (isDubleName != null)
                    {
                        if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.NAME_EN_IS_EXIST, data = Messages.EMPTY }));
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.NAME_IS_EXIST, data = Messages.EMPTY }));
                        }
                    }
                    else
                    {
                        EmployeeData isDublePhone = employeeDB.SearchByPhoneEmployee(instanceDataModel);
                        if (isDublePhone != null)
                        {
                            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.PHONE_EN_IS_EXIST, data = Messages.EMPTY }));
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.PHONE_IS_EXIST, data = Messages.EMPTY }));
                            }
                        }
                        else
                        {
                            //Translation
                            employeeValid.Translation(instanceDataModel);
                            int isAdd = employeeDB.AddEmployee(instanceDataModel);
                            if (isAdd > 0)
                            {
                                if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = Messages.EMPTY }));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = Messages.EMPTY }));
                                }
                            }
                            else
                            {
                                if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ADD_EMPLOYEE_EN_ERROR, data = Messages.EMPTY }));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ADD_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = isValid, data = Messages.EMPTY }));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ADD_EMPLOYEE_ERROR, data = Messages.EMPTY }));
            }
        }
示例#12
0
        public HttpResponseMessage GetEmployee([FromUri] EmployeeDataContext instanceDataModel)
        {
            try
            {
                if (instanceDataModel == null || instanceDataModel.language == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPLOYEE_NULL_ERROR, data = Messages.EMPTY }));
                }

                if (instanceDataModel.filterStatus == true)
                {
                    if ((ValedationClass.IsValidNameAr(instanceDataModel.textSearch) || ValedationClass.IsValidNameEn(instanceDataModel.textSearch)) == true)
                    {
                        EmployeeData dtEmployees = employeeDB.GetEmployee(instanceDataModel.textSearch, instanceDataModel.language);
                        if (dtEmployees != null)
                        {
                            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = dtEmployees }));
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = dtEmployees }));
                            }
                        }
                        else
                        {
                            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.NAME_NOT_EN_EXIST, data = Messages.EMPTY }));
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.NAME_NOT_EXIST, data = Messages.EMPTY }));
                            }
                        }
                    }
                    else
                    {
                        if (ValedationClass.IsValidNumber(instanceDataModel.textSearch) == true)
                        {
                            EmployeeData dtEmployees = employeeDB.GetEmployee(instanceDataModel.textSearch, instanceDataModel.language);
                            if (dtEmployees != null)
                            {
                                if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = dtEmployees }));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = dtEmployees }));
                                }
                            }
                            else
                            {
                                if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.PHONE_EN_NOT_EXIST, data = Messages.EMPTY }));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.PHONE_NOT_EXIST, data = Messages.EMPTY }));
                                }
                            }
                        }
                        else
                        {
                            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.CORRECT_EN_NAME_AND_PHONE, data = Messages.EMPTY }));
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.CORRECT_NAME_AND_PHONE, data = Messages.EMPTY }));
                            }
                        }
                    }
                }
                else
                {
                    return(GetAllEmployee(instanceDataModel));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPTY_EMPLOYEE_ERROR, data = Messages.EMPTY }));
            }
        }