Esempio n. 1
0
        public async Task <List <PharmacyMedicineSupply> > GetSupply(List <MedicineDemand> medicines)
        {
            pharmacies = supplyRepo.GetPharmacies();
            _log4net.Info("Pharmacies Data retrieved");
            foreach (var m in medicines)
            {
                if (m.Count > 0)
                {
                    int stockCount = await stockProvider.GetStock(m.MedicineName);

                    if (stockCount != -1)
                    {
                        if (stockCount < m.Count)
                        {
                            m.Count = stockCount;
                        }
                        int indSupply = (m.Count) / pharmacies.Count;
                        foreach (var i in pharmacies)
                        {
                            pharmacySupply.Add(new PharmacyMedicineSupply {
                                MedicineName = m.MedicineName, PharmacyName = i.pharmacyName, SupplyCount = indSupply
                            });
                        }
                        if (m.Count > indSupply * pharmacies.Count)
                        {
                            pharmacySupply[pharmacySupply.Count - 1].SupplyCount += (m.Count - indSupply * pharmacies.Count);
                        }
                    }
                }
            }
            _log4net.Info("Medicines have been successfully supplied to the pharmacies");
            return(pharmacySupply);
        }
Esempio n. 2
0
        public async Task <List <PharmacyMedicineSupply> > GetSupply(List <MedicineDemand> medicines)
        {
            pharmacies = supplyRepo.GetPharmacies();

            foreach (var m in medicines)
            {
                if (m.Count > 0)
                {
                    int stockCount = await stockProvider.GetStock(m.MedicineName);

                    if (stockCount != -1)
                    {
                        if (stockCount < m.Count)
                        {
                            m.Count = stockCount;
                        }
                        int indSupply = (m.Count) / pharmacies.Count;
                        foreach (var i in pharmacies)
                        {
                            pharmacySupply.Add(new PharmacyMedicineSupply {
                                MedicineName = m.MedicineName, PharmacyName = i.pharmacyName, SupplyCount = indSupply
                            });
                        }
                        if (m.Count > indSupply * pharmacies.Count)
                        {
                            pharmacySupply[pharmacySupply.Count - 1].SupplyCount += (m.Count - indSupply * pharmacies.Count);
                        }
                    }
                }
            }

            return(pharmacySupply);
        }