public async void RetrieveProducts()
        {
            // Arrange
            _mockProviderService.Given("products exist")
            .UponReceiving("A request to get products")
            .With(new ProviderServiceRequest
            {
                Method = HttpVerb.Get,
                Path   = "/products",
            })
            .WillRespondWith(new ProviderServiceResponse {
                Status  = 200,
                Headers = new Dictionary <string, object>
                {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body = new MinTypeMatcher(new
                {
                    id   = "27",
                    name = "burger",
                    type = "food"
                }, 1)
            });

            // Act
            var            consumer = new ProductClient();
            List <Product> result   = await consumer.GetProducts(_mockProviderServiceBaseUri);

            // Assert
            result.Should().NotBeNull();
            result.Should().HaveCount(1);
            result[0].id.Should().Equals("27");
            result[0].name.Should().Equals("burger");
            result[0].type.Should().Equals("food");
        }
        static void Main(string[] args)
        {
            string baseUri = "http://localhost:9000";

            Console.WriteLine("Fetching products");
            var            consumer = new ProductClient();
            List <Product> result   = consumer.GetProducts(baseUri).GetAwaiter().GetResult();

            Console.WriteLine(result);
        }
Esempio n. 3
0
        public StartingForm()
        {
            InitializeComponent();

            try
            {
                //Get all Products
                DataHolders.ProductsHolder.products = ProductClient.GetProducts();

                //Get all connections
                DataHolders.ButtonConnectionHolder.connections      = ButtonsClient.GetButtonConnections();
                DataHolders.UnitProductConnectionHolder.Connections = ButtonsClient
                                                                      .GetUnitPorductConnections();

                //Documents
                DataHolders.DocumentConnectionHolder.documentProductConnections = DocumentClient
                                                                                  .GetAllDocumnetProductConnections();

                //Warehouse
                DataHolders.WarehouseHolder.warehouses = DatabaseManagers.WarehouseClient.GetWarehouses();


                //DatabaseManagers.WarehouseManager.GetWarehouses();
                DataHolders.WarehouseHolder.warehouseProductConnections = DatabaseManagers.WarehouseClient
                                                                          .GetWarehouseProductConnection();

                //workers
                DataHolders.WorkerHolder.workers          = WorkerClient.GetWorkers();
                DataHolders.WorkerHolder.avaliableWorkers = WorkerClient.GetAavalibleWorkers();

                //Delivery
                DataHolders.DeliveryHolder.partners          = DeliveryClient.GetPartners();
                DataHolders.DeliveryHolder.locations         = DeliveryClient.GetLocations();
                DataHolders.DeliveryHolder.vehicles          = DeliveryClient.GetVehicles();
                DataHolders.DeliveryHolder.routes            = DeliveryClient.GetRoutes();
                DataHolders.DeliveryHolder.avaliableVehicles = DeliveryClient.GetAvalibleVehicles();

                //properties
                if (PropertiesClient.GetProperties().Exists((e) => e.name == Enums.PropertyName.distance))
                {
                    DataHolders.PropertiesHolder.distanceUnit = PropertiesClient.GetProperties()
                                                                .Find((e) => e.name == Enums.PropertyName.distance).value;
                }
                if (PropertiesClient.GetProperties().Exists((e) => e.name == Enums.PropertyName.weight))
                {
                    DataHolders.PropertiesHolder.weightUnit = PropertiesClient.GetProperties()
                                                              .Find((e) => e.name == Enums.PropertyName.weight).value;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error connecting to database, initial data couldn't be load");
                Environment.Exit(1);
            }
        }
 public async Task <List <ProductResponse> > GetProducts()
 {
     try
     {
         return(await _client.GetProducts());
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Esempio n. 5
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         ProductsHolder.products = ProductClient.GetProducts();
     }
     catch (Exception)
     {
         MessageBox.Show("Failed to refresh from database");
     }
     dgvProducts.DataSource = ProductsHolder.products;
 }
Esempio n. 6
0
        public static void ProductGetProductsTest()
        {
            var client            = new ProductClient();
            var resultGetProducts = client.GetProducts(siteId, userName, password,
                                                       @"<LeadForceRequest>
	<Product>
		<Params>			
			<Brand value=""ElfNet"" />
        </Params>
    </Product>
</LeadForceRequest>");

            Console.WriteLine(resultGetProducts);
        }
Esempio n. 7
0
        public async Task <IActionResult> Index()
        {
            var productList = await _productClient.GetProducts();

            if (productList.IsSuccess)
            {
                ViewBag.ProductList = productList.Data;
            }
            var userList = await _userRepository.GetAllAsync();

            ViewBag.UserList = userList;

            var auctionList = await _auctionClient.GetAuctions();

            if (auctionList.IsSuccess)
            {
                return(View(auctionList.Data));
            }
            else
            {
                return(View());
            }
        }
        public async Task <IActionResult> Create()
        {
            //TODO:Product GetAll
            var productList = await _productClient.GetProducts();

            if (productList.IsSuccess)
            {
                ViewBag.ProductList = productList.Data;
            }

            var userList = await _userRepository.GetAllAsync();

            ViewBag.UserList = userList;

            return(View());
        }
 public async Task <List <ProductModel> > GetProducts()
 {
     return(await client.GetProducts(_token));
 }