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; } }
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; } }
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; }
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(); }
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; }
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); } }
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; } }
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()); }
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); }