예제 #1
0
 public static void AddPackage(Package package)
 {
     using (var context = new Entities())
     {
         context.Packages.Add(package);
         context.SaveChanges();
     }
 }
예제 #2
0
        public void RegisterPackage(Package pkg)
        {
            PackageStatus pkgStatus = new PackageStatus();
            PackageDAO pkgDao = new PackageDAO();
            PackageStatusDAO pkgStatusDao = new PackageStatusDAO();

            pkgStatus.Status = "InStock";
            pkgStatus.CentreSource = this.DistributionCentre;
            pkgStatus.CentreDestination = null;

            pkgDao.insertPackage(pkg);
            pkgStatusDao.insertPackageStatus(pkgStatus);
        }
예제 #3
0
 public void PackageDatabaseTest_InsertPackage_PackageTotalAdded()
 {
     Package package = new Package();
     //PackageDAO.insertPackage(package);
 }
예제 #4
0
        /// <summary>
        /// Registers the package to the system and returns the barcode
        /// </summary>
        /// <param name="expiryDate">Expiry date of the package</param>
        /// <param name="medicationId">The medication ID</param>
        /// <returns>Barcode</returns>
        public static int RegisterPackage(DateTime expiryDate, int medicationId)
        {
            Package p = new Package();
            p.ExpiryDate = expiryDate;
            p.PackageStandardTypeId = medicationId;
            int result = -1;
            if (ValidateInput(expiryDate) == Result.Ok)
            {
                using (var context = new Entities())
                {
                    context.Packages.Add(p);
                    context.SaveChanges();

                    return p.PackageId;
                }
            }
            return result;
        }
예제 #5
0
        public void RegisterPackage_PackageDetails_BarcodeExist()
        {
            //NOTE: Uncomment when method already updated

            //Package newPackage = createMockPackage();
            //newPackage.Medication = createMockMedication();
            Package pkg = new Package();
            MedicationStandardType med = new MedicationStandardType();

            med.Id = 1;

            pkg.BarCode = 123457;
            pkg.ExpiryDate =  new DateTime(17, 12, 12);
            pkg.Medication = med;
            pkg.Quantity = 2;

            _agent.RegisterPackage(pkg);
            Assert.AreNotEqual(null, pkg.BarCode);
            Assert.AreNotEqual(null, pkg.ExpiryDate);
            Assert.AreNotEqual(null, pkg.Medication.Id);
            Assert.AreNotEqual(null, pkg.Quantity);
        }