Exemple #1
0
        public ActionResult RegisterPackage(Package package)
        {
            int barcode = 0;

            if (Request.Form["Register"] != null)
            {
                barcode = packageServies.AddPackage(package, WebSecurity.CurrentUserId);
            }
            ListMedication();
            return(View(package));
        }
        public void AddPackageTest()
        {
            int userID  = 1;
            int barcode = packageService.AddPackage(testPack, userID);
            var pack    = packageDao.Packages.SingleOrDefault(Package => Package.Barcode == barcode);
            int result  = pack.Barcode;

            packageDao.Packages.Remove(pack);
            packageDao.SaveChanges();
            Assert.AreEqual(barcode, result);
        }
        public void AddDocumentsToPackagesTest()
        {
            //Arrange
            setUp();
            PackageService s = new PackageService();

            //Act
            var Repository = new DocuRepository(MockContext);
            int p          = s.AddPackage("foo");
            int p2         = s.AddPackage("bar");

            s.AddDocumentToPackage(Repository.GetDocumentByName("Test Document").DocumentID, p);
            s.AddDocumentToPackage(Repository.GetDocumentByName("Test Document 2").DocumentID, p);
            s.AddDocumentToPackage(Repository.GetDocumentByName("Test Document 2").DocumentID, p2);

            //Assert
            Assert.AreEqual(Repository.GetPDs().Count(), 3);
            Assert.AreEqual(Repository.GetPDsByDocName("Test Document").Count(), 1);
            Assert.AreEqual(Repository.GetPDsByDocName("Test Document 2").Count(), 2);
            Assert.AreEqual(Repository.GetPDsByDocName("foo").Count(), 2);
            Assert.AreEqual(Repository.GetPDsByDocName("bar").Count(), 1);
        }
        public void AddPackageTest()
        {
            //Arrange
            setUp();
            PackageService s    = new PackageService();
            var            name = "adifjfej23";

            //Act
            var Repository = new DocuRepository(MockContext);
            int p          = s.AddPackage(name);

            //Assert
            Assert.AreEqual(name, Repository.GetPackageByID(p).Name);
            Assert.AreEqual(Repository.GetPDs().Count(), 0);

            IEnumerable <Package> result = Repository.GetPackages();

            Assert.AreEqual(result.Count(), 1);
        }
Exemple #5
0
        public ActionResult Create(PackageModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var package = Mapper.Map <Package>(model);
                    var result  = PackageService.AddPackage(package);

                    if (result.Succes)
                    {
                        return(RedirectToAction("List"));
                    }
                }
            }
            catch
            {
                return(View(model));
            }
            return(View(model));
        }
        public int PostNewPackage(string name)
        {
            var ps = new PackageService();

            return(ps.AddPackage(name));
        }