public Shipment Send(DrugTypesInDepot drugTypesInDepot)
        {
            var drugUnits = (from d in entity
                             where d.DepotId == drugTypesInDepot.DepotId
                             where d.Shipped == false
                             select d).ToList();


            var shippedDrugUnitsId = new List <string>();
            var unshippedDrugUnits = new Dictionary <string, int>();

            foreach (var d in drugTypesInDepot.AvailableDrugTypes)
            {
                var drugUnitWithType = (from t in drugUnits
                                        where t.DrugTypeId == d.DrugTypeId
                                        select t).ToList();

                int shippedCount;
                int unshippedCount = 0;
                if (d.Quantity < 0)
                {
                    shippedCount = 0;
                }
                if ((drugUnitWithType.Count - d.Quantity) < 0)
                {
                    shippedCount   = drugUnitWithType.Count;
                    unshippedCount = d.Quantity - drugUnitWithType.Count;
                    unshippedDrugUnits.Add(d.DrugTypeName, unshippedCount);
                }
                else
                {
                    shippedCount = d.Quantity;
                }

                for (int i = 0; i < shippedCount; i++)
                {
                    drugUnitWithType[i].Shipped = true;
                    shippedDrugUnitsId.Add(drugUnitWithType[i].DrugUnitId);
                }
            }
            db.SaveChanges();

            return(new Shipment
            {
                Shipped = shippedDrugUnitsId,
                Unshipped = unshippedDrugUnits
            });
        }
        public ActionResult Send(DrugTypesInDepot drugTypesInDepot)
        {
            Shipment shipment = Database.DrugUnits.Send(drugTypesInDepot);

            return(View("Display", shipment));
        }