示例#1
0
        public static void AreEqual(Package package, PackagePageModel packagePageModel)
        {
            if (package == null) { throw new ArgumentNullException("package"); }
            if (packagePageModel == null) { throw new ArgumentNullException("packagePageModel"); }

            Assert.AreEqual(package.Id, packagePageModel.Id);
            Assert.AreEqual(package.Name, packagePageModel.Name);
            Assert.AreEqual(package.PackageLocation, packagePageModel.PackageLocation);
            Assert.AreEqual(packagePageModel.PackageManifest, packagePageModel.PackageManifest);
            Assert.AreEqual(package.Version, packagePageModel.Version);

            string tagString = CustomAssert.ConvertTagsToString(package.Tags);
            Assert.AreEqual(packagePageModel.Tags.Replace(" ", string.Empty), tagString);
        }
        public ActionResult AddPackage(PackagePageModel package)
        {
            if (package == null) { throw new ArgumentNullException("package"); }

            ValidateModel(package);

            if (ModelState.IsValid) {

                Package actualPacakge = ObjectMapper.Instance.Map<PackagePageModel, Package>(package);
                this.PackageRepository.AddPackage(actualPacakge);

                return RedirectToAction("Index");
            }
            else {
                // TODO: Add error details here
                return View(package);
            }
        }