Ejemplo n.º 1
0
        private void loadMedicines()
        {
            var request = new QueryRequestOfProductQueryVmy3cGwc();
            request.Query = new ProductQuery()
            {
                ByPharmacyId = pharmacy.ID
            };

            var response = client.GetMatchingProducts(request);

            foreach (var product in response.Data)
            {
                var medicine = getMedicineById(product.MedicineId);
                stanMagazynuDataGridView.Rows.Add();
                int rowIndex = stanMagazynuDataGridView.Rows.Count - 1;
                DataGridViewRow newRow = stanMagazynuDataGridView.Rows[rowIndex];
                newRow.Cells["Zarzadzanie_ProductNameHeader"].Value = medicine.CommercialName;
                newRow.Cells["Zarzadzanie_ProductPriceHeader"].Value = product.Price;
                newRow.Cells["Zarzadzanie_ProductOnStockHeader"].Value = product.OnStock;
                newRow.Tag = product;
            }
        }
Ejemplo n.º 2
0
        private void MedicineDetails_Load(object sender, EventArgs e)
        {
            MainForm owner = Owner as MainForm;
            client = owner.client;

            var pharmacy = new QueryRequestOfProductQueryVmy3cGwc();
            pharmacy.Query = new ProductQuery()
            {
                ByMedicineId = medicineDto.MedicineId
            };
            var responsePharmacy = client.GetMatchingProducts(pharmacy);

            foreach (var product in responsePharmacy.Data)
            {
                medicinesDataGridView.Rows.Add();
                int rowIndex = medicinesDataGridView.Rows.Count - 1;
                DataGridViewRow newRow = medicinesDataGridView.Rows[rowIndex];
                newRow.Cells["aptekaColumn"].Value = medicineDto.CommercialName;
                newRow.Cells["cenaColumn"].Value = product.Price;
                newRow.Cells["iloscColumn"].Value = product.OnStock;
                newRow.Tag = product;
            }
        }
Ejemplo n.º 3
0
        private static IList<ProductDto> FindProduct()
        {
            Console.WriteLine("Podaj id produktu:");

            string searchString = Console.ReadLine();

            var request = new QueryRequestOfProductQueryVmy3cGwc();
            int? productId = null;
            try
            {
                productId = int.Parse(searchString);
            }
            catch (Exception)
            { }

            request.Query = new ProductQuery()
            {
                ByProductId = productId
            };

            var response = client.GetMatchingProducts(request);

            Console.WriteLine("Odpowiedź: " + response.Message);

            foreach (var p in response.Data)
            {
                Console.WriteLine("ID: " + p.ProductId);
                Console.WriteLine("PharmacyID: " + p.PharmacyId);
                Console.WriteLine("MedicineID: " + p.MedicineId);
            }

            return response.Data;
        }
Ejemplo n.º 4
0
        private static ProductDto GetProductById(int productId)
        {
            var request = new QueryRequestOfProductQueryVmy3cGwc();
            request.Query = new ProductQuery()
            {
                ByProductId = productId
            };

            var response = client.GetMatchingProducts(request);
            return response.Data.FirstOrDefault();
        }
Ejemplo n.º 5
0
        private static IEnumerable<ProductDto> GetProducstByPharmacyId(int pharmacyId)
        {
            var request = new QueryRequestOfProductQueryVmy3cGwc();
            request.Query = new ProductQuery()
            {
                ByPharmacyId = pharmacyId
            };

            var response = client.GetMatchingProducts(request);
            return response.Data;
        }
Ejemplo n.º 6
0
        private void aptekiListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (aptekiListView.SelectedItems.Count <= 0)
                return;
            lekiListView.Items.Clear();
            PharmacyDto pharmacy = aptekiListView.SelectedItems[0].Tag as PharmacyDto;
            var request = new QueryRequestOfProductQueryVmy3cGwc();
            request.Query = new ProductQuery()
            {
                ByPharmacyId = pharmacy.ID
            };

            var response = client.GetMatchingProducts(request);

            foreach (var product in response.Data)
            {
                var medicine = getMedicineById(product.MedicineId);
                ListViewItem item = new ListViewItem(medicine.CommercialName);
                item.Tag = product;
                lekiListView.Items.Add(item);
            }
        }
Ejemplo n.º 7
0
        private void findMedicine(string searchString)
        {
            var request = new QueryRequestOfMedicineQueryVmy3cGwc();
            int? medicineId = null;
            try
            {
                medicineId = int.Parse(searchString);
            }

            catch (Exception)
            { }

            request.Query = new MedicineQuery()
            {
                ById = medicineId,
                ByCommercialName = searchString
            };

            var response = client.GetMatchingMedicines(request);

            foreach (var p in response.Data)
            {
                var pharmacy = new QueryRequestOfProductQueryVmy3cGwc();
                pharmacy.Query = new ProductQuery()
                {
                    ByMedicineId = p.MedicineId
                };
                var responsePharmacy = client.GetMatchingProducts(pharmacy);
                string lowestPrice;
                try
                {
                    lowestPrice = responsePharmacy.Data.Min(prod => prod.Price).ToString();
                }
                catch (Exception)
                {
                    lowestPrice = "Brak produktu w magazynach";
                }

                lekiDataGridView.Rows.Add();
                int rowIndex = lekiDataGridView.Rows.Count - 1;
                DataGridViewRow newRow = lekiDataGridView.Rows[rowIndex];
                newRow.Cells["nazwaLekuColumn"].Value = p.CommercialName;
                newRow.Cells["najnizszaCenaColumn"].Value = lowestPrice;
                newRow.Tag = p;
            }
        }
Ejemplo n.º 8
0
        public void GetMatchingProductsByPharmacyIdTest()
        {
            const int pharmacyId = 1;
            var request = new QueryRequestOfProductQueryVmy3cGwc();
            request.Query = new ProductQuery()
            {
                ByPharmacyId = pharmacyId
            };

            var response = _aptekaNetServiceClient.GetMatchingProducts(request);
            var products = response.Data;

            int dbProductsCount;
            using (var unitOfWork = new AptekaNetUnitOfWork())
            {
                dbProductsCount = unitOfWork.ProductRepository.All().Count(p => p.Pharmacy.Id == pharmacyId);
            }
            Assert.AreEqual(dbProductsCount, products.Count());
        }
Ejemplo n.º 9
0
        public void GetMatchingProductsByIdTest()
        {
            int productId = 1;
            var request = new QueryRequestOfProductQueryVmy3cGwc();
            request.Query = new ProductQuery()
            {
                ByProductId = productId
            };

            var response = _aptekaNetServiceClient.GetMatchingProducts(request);
            var product = response.Data.FirstOrDefault();

            Assert.AreEqual(productId, product.ProductId);
        }