Пример #1
0
        private void addPharmaciesToListView()
        {
            var pharmacyRequest = new QueryRequestOfPharmacyQueryVmy3cGwc()
            {
                Query = new PharmacyQuery()
            };
            var pharmacyResponse = client.GetMatchingPharmacies(pharmacyRequest);

            foreach (var pharmacy in pharmacyResponse.Data)
            {
                ListViewItem item = new ListViewItem(pharmacy.Name);
                item.Tag = pharmacy;
                aptekiListView.Items.Add(item);
            }
        }
Пример #2
0
        private static IList<PharmacyDto> FindPharmacy()
        {
            Console.WriteLine("Podaj id,nazwe lub fragment adresu apteki:");

            string searchString = Console.ReadLine();

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

            request.Query = new PharmacyQuery()
            {
                ById = pharmacyId,
                ByAddress = searchString,
                ByName = searchString
            };

            var response = client.GetMatchingPharmacies(request);

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

            foreach (var p in response.Data)
            {
                Console.WriteLine("ID: " + p.ID);
                Console.WriteLine("Nazwa: " + p.Name);
                Console.WriteLine("Adres: " + p.Address);
                Console.WriteLine("Telefon: " + p.Phone);
                Console.WriteLine("Opis: " + p.Description);
            }

            return response.Data;
        }
Пример #3
0
        private static void PlaceOrder()
        {
            try
            {
                Console.WriteLine("Lista aptek:");
                Console.WriteLine();
                var request = new QueryRequestOfPharmacyQueryVmy3cGwc()
                    {
                        Query = new PharmacyQuery()
                    };
                var pharmacies = client.GetMatchingPharmacies(request).Data;

                foreach (var p in pharmacies)
                {
                    Console.WriteLine("ID: " + p.ID);
                    Console.WriteLine("Nazwa: " + p.Name);
                    Console.WriteLine("Adres: " + p.Address);
                    Console.WriteLine("Telefon: " + p.Phone);
                    Console.WriteLine("Opis: " + p.Description);
                }
                Console.WriteLine();

                Console.Write("Podaj id apteki: ");
                int pharmacyId = int.Parse(Console.ReadLine());
                var pharmacy = GetPharmacyById(pharmacyId);
                if (pharmacy == null)
                {
                    Console.WriteLine("Nie ma takiej apteki");
                    return;
                }
                Console.WriteLine("Produkty w tej aptece: ");
                var productIdQuantityDictionary = new Dictionary<int, int>();
                var productsInPharmacy = GetProducstByPharmacyId(pharmacyId);

                Console.WriteLine();
                foreach (var product in productsInPharmacy)
                {
                    var medicine = GetMedicineById(product.MedicineId);
                    Console.WriteLine("Id produktu: {0}", product.ProductId);
                    Console.WriteLine("Id apteki: {0}", product.PharmacyId);
                    Console.WriteLine("Nazwa: {0}", medicine.CommercialName);
                    Console.WriteLine("Ilość w magazynie: {0}", product.OnStock);
                    Console.WriteLine("Cena: {0}", product.Price);
                    Console.WriteLine();
                }

                Console.WriteLine("Wybierz produkty:");
                for (int i = 0; i < productsInPharmacy.Count(); i++)
                {
                    Console.Write("Podaj id produktu (0 - zakoncz zamowienie):");
                    int id = int.Parse(Console.ReadLine());
                    if (id == 0)
                        break;

                    Console.Write("Podaj ilość: ");
                    int q = int.Parse(Console.ReadLine());
                    productIdQuantityDictionary.Add(id, q);

                }
                var orderRequest = new OrderRequest()
                    {
                        ProductIdQuantityDictionary = productIdQuantityDictionary
                    };
                var response = client.PlaceOrder(orderRequest);
                Console.WriteLine(response.Message);
            }
            catch (Exception)
            {
                Console.WriteLine("Error");
                throw;
            }
        }
Пример #4
0
        private static PharmacyDto GetPharmacyById(int id)
        {
            var pharmacyRequest = new QueryRequestOfPharmacyQueryVmy3cGwc();
            pharmacyRequest.Query = new PharmacyQuery()
            {
                ById = id
            };

            var pharmacyResponse = client.GetMatchingPharmacies(pharmacyRequest);
            return pharmacyResponse.Data.FirstOrDefault();
        }
Пример #5
0
        private void findPharmacy(string searchString)
        {
            var request = new QueryRequestOfPharmacyQueryVmy3cGwc();
            int? pharmacyId = null;
            try
            {
                pharmacyId = int.Parse(searchString);
            }
            catch (Exception)
            { }

            request.Query = new PharmacyQuery()
            {
                ById = pharmacyId,
                ByAddress = searchString,
                ByName = searchString
            };

            var response = client.GetMatchingPharmacies(request);

            foreach (var p in response.Data)
            {
                listaAptekDataGridView.Rows.Add();
                int rowIndex = listaAptekDataGridView.Rows.Count - 1;
                DataGridViewRow newRow = listaAptekDataGridView.Rows[rowIndex];
                newRow.Cells["nazwaAptekiColumn"].Value = p.Name;
                newRow.Cells["adresColumn"].Value = p.Address;
                newRow.Tag = p;
            }
        }
Пример #6
0
        public void GetMatchingPharmaciesByNameTest()
        {
            var pharmacyRequest = new QueryRequestOfPharmacyQueryVmy3cGwc();
            string namePart = "Puławska";
            pharmacyRequest.Query = new PharmacyQuery()
            {
                ByName = namePart
            };

            var pharmacyResponse = _aptekaNetServiceClient.GetMatchingPharmacies(pharmacyRequest);
            var pharmacies = pharmacyResponse.Data;

            int dbPharmacyCount;
            using (var unitOfWork = new AptekaNetUnitOfWork())
            {
                dbPharmacyCount =
                    unitOfWork.PharmacyRepository.All().Count(p => p.Name.ToLower().Contains(namePart));
            }
            Assert.AreEqual(dbPharmacyCount, pharmacies.Count());
        }
Пример #7
0
        public void GetMatchingPharmaciesByIdTest()
        {
            int pharmacyId = 1;

            var pharmacyRequest = new QueryRequestOfPharmacyQueryVmy3cGwc();
            pharmacyRequest.Query = new PharmacyQuery()
            {
                ById = pharmacyId
            };

            var pharmacyResponse = _aptekaNetServiceClient.GetMatchingPharmacies(pharmacyRequest);
            var pharmacy = pharmacyResponse.Data.FirstOrDefault();
            Assert.AreEqual(pharmacyId, pharmacy.ID);
        }