private static ExigoContext GetNewODataContext(ExigoApiContextSource source)
        {
            var sourceUrl = "";

            switch (source)
            {
            case ExigoApiContextSource.Live:
                sourceUrl = GlobalSettings.ExigoApiSettings.OData.LiveUrl;
                break;

            case ExigoApiContextSource.Sandbox1:
                sourceUrl = GlobalSettings.ExigoApiSettings.OData.Sandbox1Url;
                break;

            case ExigoApiContextSource.Sandbox2:
                sourceUrl = GlobalSettings.ExigoApiSettings.OData.Sandbox2Url;
                break;

            case ExigoApiContextSource.Sandbox3:
                sourceUrl = GlobalSettings.ExigoApiSettings.OData.Sandbox3Url;
                break;
            }

            var context = new ExigoContext(new Uri(sourceUrl + "/model"));

            context.IgnoreMissingProperties         = true;
            context.IgnoreResourceNotFoundException = true;
            var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(LoginName + ":" + Password));

            context.SendingRequest +=
                (object s, SendingRequestEventArgs e) =>
                e.RequestHeaders.Add("Authorization", "Basic " + credentials);
            return(context);
        }
        private static ExigoApi GetNewWebServiceContext(ExigoApiContextSource source)
        {
            var sourceUrl = "";

            switch (source)
            {
            case ExigoApiContextSource.Live:
                sourceUrl = GlobalSettings.ExigoApiSettings.WebService.LiveUrl;
                break;

            case ExigoApiContextSource.Sandbox1:
                sourceUrl = GlobalSettings.ExigoApiSettings.WebService.Sandbox1Url;
                break;

            case ExigoApiContextSource.Sandbox2:
                sourceUrl = GlobalSettings.ExigoApiSettings.WebService.Sandbox2Url;
                break;

            case ExigoApiContextSource.Sandbox3:
                sourceUrl = GlobalSettings.ExigoApiSettings.WebService.Sandbox3Url;
                break;
            }

            return(new ExigoApi
            {
                ApiAuthenticationValue = new Exigo.WebService.ApiAuthentication
                {
                    LoginName = LoginName,
                    Password = Password,
                    Company = Company
                },
                Url = sourceUrl
            });
        }
        private static ExigoContext GetNewODataContext(ExigoApiContextSource source)
        {
            var sourceUrl = "";
            switch(source)
            {
                case ExigoApiContextSource.Live:
                    sourceUrl = GlobalSettings.ExigoApiSettings.OData.LiveUrl;
                    break;
                case ExigoApiContextSource.Sandbox1:
                    sourceUrl = GlobalSettings.ExigoApiSettings.OData.Sandbox1Url;
                    break;
                case ExigoApiContextSource.Sandbox2:
                    sourceUrl = GlobalSettings.ExigoApiSettings.OData.Sandbox2Url;
                    break;
                case ExigoApiContextSource.Sandbox3:
                    sourceUrl = GlobalSettings.ExigoApiSettings.OData.Sandbox3Url;
                    break;
            }

            var context = new ExigoContext(new Uri(sourceUrl + "/model"));
            context.IgnoreMissingProperties = true;
            context.IgnoreResourceNotFoundException = true;
            var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(LoginName + ":" + Password));
            context.SendingRequest +=
                (object s, SendingRequestEventArgs e) =>
                    e.RequestHeaders.Add("Authorization", "Basic " + credentials);
            return context;
        }
 public static ExigoContext CreateODataContext(ExigoApiContextSource source)
 {
     return(GetNewODataContext(source));
 }
 public static ExigoApi CreateWebServiceContext(ExigoApiContextSource source)
 {
     return(GetNewWebServiceContext(source));
 }
 public static ExigoApi CreateWebServiceContext(ExigoApiContextSource source)
 {
     return GetNewWebServiceContext(source);
 }
 public static ExigoContext CreateODataContext(ExigoApiContextSource source)
 {
     return GetNewODataContext(source);
 }
        private static ExigoApi GetNewWebServiceContext(ExigoApiContextSource source)
        {
            var sourceUrl = "";
            switch(source)
            {
                case ExigoApiContextSource.Live:
                    sourceUrl = GlobalSettings.ExigoApiSettings.WebService.LiveUrl;
                    break;
                case ExigoApiContextSource.Sandbox1:
                    sourceUrl = GlobalSettings.ExigoApiSettings.WebService.Sandbox1Url;
                    break;
                case ExigoApiContextSource.Sandbox2:
                    sourceUrl = GlobalSettings.ExigoApiSettings.WebService.Sandbox2Url;
                    break;
                case ExigoApiContextSource.Sandbox3:
                    sourceUrl = GlobalSettings.ExigoApiSettings.WebService.Sandbox3Url;
                    break;
            }

            return new ExigoApi
            {
                ApiAuthenticationValue = new Exigo.WebService.ApiAuthentication
                {
                    LoginName = LoginName,
                    Password = Password,
                    Company = Company
                },
                Url = sourceUrl
            };
        }