public static void AddPackage(Package package) { using (var context = new Entities()) { context.Packages.Add(package); context.SaveChanges(); } }
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); }
public void PackageDatabaseTest_InsertPackage_PackageTotalAdded() { Package package = new Package(); //PackageDAO.insertPackage(package); }
/// <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; }
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); }