コード例 #1
0
            public void NextAvailableCopyNumberIncrementsCopyNumberUsingCount()
            {
                holdingRepo.Create(new Holding("AB123:1"));
                holdingRepo.Create(new Holding("AB123:2"));
                holdingRepo.Create(new Holding("XX123:1"));

                var copyNumber = HoldingsControllerUtil.NextAvailableCopyNumber(holdingRepo, "AB123");

                Assert.That(copyNumber, Is.EqualTo(3));
            }
コード例 #2
0
        public Holding AddNewMaterial(string isbn)
        {
            var classification = classificationService.Classification(isbn);
            var holding        = new Holding
            {
                Classification = classification,
                CopyNumber     = HoldingsControllerUtil.NextAvailableCopyNumber(holdingRepo, classification),
                BranchId       = BranchId
            };

            holdingRepo.Create(holding);
            return(holding);
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,Classification,CopyNumber,CheckOutTimestamp,BranchId,HeldByPatronId,LastCheckedIn")] Holding holding)
        {
            if (ModelState.IsValid)
            {
                if (holding.CopyNumber == 0)
                {
                    holding.CopyNumber = HoldingsControllerUtil.NextAvailableCopyNumber(holdingRepo, holding.Classification);
                }
                else
                {
                    if (HoldingsControllerUtil.FindByBarcode(holdingRepo, holding.Barcode) != null)
                    {
                        ModelState.AddModelError(ModelKey, "Duplicate classification / copy number combination.");
                        return(View(holding));
                    }
                }

                var id = holdingRepo.Create(holding);
                return(RedirectToAction("Index", new { ID = id }));
            }
            return(View(holding));
        }