public ActionResult RegisterPackage(Package package)
 {
     int barcode = 0;
     if(Request.Form["Register"] != null)
     {
         barcode = packageServies.AddPackage(package, WebSecurity.CurrentUserId);
     }
     ListMedication();
     return View(package);
 }
        public int AddPackage(Package pack, int userID)
        {
            //Form Proper package types
            pack.UserId = userID;
            pack.DistributionCenterID = employeeLoginDao.GetEmployeeLoginDetail(userID).DistributionCenterID;
            pack.ReceivingCenterID = null;
            pack.StockStatus = StockType.InStock;
            pack.TransactionDate = DateTime.Today;

            return packageDao.RegisterPackage(pack);
        }
 public PackageTest()
 {
     packageService = new PackageService();
     packageDao = new PackageDAO();
     testPack = new Package();
     testPack.UserId = 1;
     testPack.MedicalID = 1;
     testPack.ExpiryDate = DateTime.Today;
     testPack.DistributionCenterID = 1;
     testPack.ReceivingCenterID = null;
     testPack.TransactionDate = DateTime.Today;
 }
 public ActionResult DistributePackage(Package pack)
 {
     if (Request.Form["SearchBarcode"] != null)
     {
         return View(packageServies.CheckIfBarcodeExist(pack.Barcode, StockType.InStock));
     }
     else if (Request.Form["DistributePackageConfirm"] != null)
     {
         packageServies.UpdatePackageStatus(WebSecurity.CurrentUserId, pack.Barcode, StockType.Distributed, null);
     }
     return View();
 }
 public ActionResult SendPackage(Package pack)
 {
     ViewBag.DistributionCenters = new DistributionCenterService().GetDistributionCenterList();
     if (Request.Form["SearchBarcode"] != null)
     {
         return View(packageServies.CheckIfBarcodeExist(pack.Barcode, StockType.InStock));
     }
     else if(Request.Form["SendPackageConfirm"] != null)
     {
         packageServies.UpdatePackageStatus(WebSecurity.CurrentUserId, pack.Barcode, StockType.InTransit, pack.ReceivingCenterID.Value);
     }
     return View();
 }
 public Package CheckIfPackageExist(int barCode, StockType? stockType)
 {
     var pack = new Package();
     if (stockType != null)
     {
         pack = Packages.SingleOrDefault(Package => Package.Barcode == barCode && Package.StockStatus == stockType);
     }
     else
     {
         pack = Packages.SingleOrDefault(Package => Package.Barcode == barCode);
     }
     return pack;
 }
        public ActionResult AuditPackage(Package pack, string actionType)
        {
            if (Request.Form["SearchBarcode"] != null)
            {
                return View(packageServies.CheckIfBarcodeExist(pack.Barcode, null));
            }
            else if (Request.Form["AuditFeature"] != null)
            {
                StockType stockType = StockType.InStock;
                if (actionType.CompareTo("InStock") == 0)
                    stockType = StockType.InStock;

                if (actionType.CompareTo("Discard") == 0)
                    stockType = StockType.Discarded;

                if (actionType.CompareTo("Lost") == 0)
                    stockType = StockType.Lost;

                if (actionType.CompareTo("Remove") == 0)
                {
                    packageServies.RemovePackage(pack.Barcode);
                }
                else
                    packageServies.UpdatePackageStatus(WebSecurity.CurrentUserId, pack.Barcode, stockType, null);
            }
            return View();
        }
 public int RegisterPackage(Package pack)
 {
     Packages.Add(pack);
     SaveChanges();
     return pack.Barcode;
 }