Exemple #1
0
 public static List <Order> GetOrders(AutoServiceDataSource dataSource)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(baseAdress);
         HttpResponseMessage response = client.GetAsync(controllerName + $"?dataSource={dataSource}").Result;
         if (response.IsSuccessStatusCode)
         {
             return(response.Content.ReadAsAsync <List <Order> >().Result);
         }
         else
         {
             return(null);
         }
     }
 }
Exemple #2
0
 public static SharedModels.Client GetClient(int orderId, AutoServiceDataSource dataSource)
 {
     using (var client = new HttpClient())
     {
         client.BaseAddress = new Uri(baseAdress);
         HttpResponseMessage response = client.GetAsync(controllerName + $"?dataSource={dataSource}&id={orderId}").Result;
         if (response.IsSuccessStatusCode)
         {
             return(response.Content.ReadAsAsync <SharedModels.Client>().Result);
         }
         else
         {
             return(null);
         }
     }
 }
        // GET api/AutoService/5
        public Client Get(int id, AutoServiceDataSource dataSource = AutoServiceDataSource.DB)
        {
            switch (dataSource)
            {
            case AutoServiceDataSource.XML:
                _container.RegisterType <IAutoServiceDataProvider, XMLDataProvider>(new ContainerControlledLifetimeManager());
                break;

            case AutoServiceDataSource.Binary:
                _container.RegisterType <IAutoServiceDataProvider, BinaryDataProvider>(new ContainerControlledLifetimeManager());
                break;

            default:
                _container.RegisterType <IAutoServiceDataProvider, DBDataProvider>(new ContainerControlledLifetimeManager());
                break;
            }
            return(_container.Resolve <IAutoServiceDataProvider>(new ParameterOverride("dir", DataDirectory())).GetClient(id));
        }