public HttpResponseMessage GetOperators(HttpRequestMessage request)
        {
            IEnumerable <string> token = null;

            request.Headers.TryGetValues("Token-autorization", out token);

            PersonEN personVerified = personBL.VerifyPersonAuthentication(token);

            if (token != null)
            {
                if (personVerified != null)
                {
                    if (personVerified.IsValidToken)
                    {
                        List <OperatorEN> theOperatorsList = operatorBL.GetOperatorList(personVerified.CountryID);

                        if (theOperatorsList != null)
                        {
                            OperatorsResponse operatorsResponse = interactor.CreateOperatorResponse(theOperatorsList);
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, operatorsResponse));
                        }
                        else
                        {
                            response.HttpCode = 500;
                            response.Message  = "Something went wrong";
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                        }
                    }
                    else
                    {
                        response.HttpCode = 401;
                        response.Message  = "Authentication token has expired.";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                    }
                }
                else
                {
                    response.HttpCode = 401;
                    response.Message  = "Credentials are not valid.";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response));
                }
            }
            else
            {
                response.HttpCode = 400;
                response.Message  = "Authorization token must be provided";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
        public OperatorsResponse CreateOperatorResponse(List <OperatorEN> pOperators)
        {
            OperatorsResponse response  = new OperatorsResponse();
            Operators         operators = new Operators();

            operators.countryOperators = new List <CountryOperators>();

            foreach (var countryOperatr in pOperators)
            {
                CountryOperators _countryOperator = new CountryOperators();

                _countryOperator.operatorID   = countryOperatr.OperatorID;
                _countryOperator.name         = countryOperatr.Name;
                _countryOperator.brand        = countryOperatr.Brand;
                _countryOperator.mnc          = countryOperatr.Mnc;
                _countryOperator.operatorLogo = countryOperatr.OperatorLogo;
                _countryOperator.logoUrl      = countryOperatr.LogoUrl;
                _countryOperator.logoVersion  = countryOperatr.LogoVersion;
                _countryOperator.HexColor     = countryOperatr.HEXColor;
                _countryOperator.RGBColor     = countryOperatr.RGBColor;
                _countryOperator.Relevance    = countryOperatr.Relevance;

                RGBColors rgbColor = new RGBColors();
                if (!string.IsNullOrEmpty(countryOperatr.RGBColor))
                {
                    var codeColor = countryOperatr.RGBColor.Split(',');
                    rgbColor.R = int.Parse(codeColor[0].ToString());
                    rgbColor.G = int.Parse(codeColor[1].ToString());
                    rgbColor.B = int.Parse(codeColor[2].ToString());
                }

                _countryOperator.rgbColor = rgbColor;


                operators.countryOperators.Add(_countryOperator);
            }

            response.operators = operators;
            response.count     = operators.countryOperators.Count;

            return(response);
        }