예제 #1
0
 public void ParsesCopyNoFromBarcode()
 {
     try
     {
         Assert.Equal(3, Holding.CopyNumberFromBarcode(ExpectedBarcode));
     }
     catch (FormatException)
     {
         Assert.False(true, "test threw format exception");
     }
 }
예제 #2
0
 public void ParsesCopyNoFromBarcode()
 {
     try
     {
         Assert.That(Holding.CopyNumberFromBarcode(ExpectedBarcode), Is.EqualTo(3));
     }
     catch (FormatException)
     {
         Assert.Fail("test threw format exception");
     }
 }
예제 #3
0
 public void CopyNumberFromBarcodeThrowsWhenNoColonExists()
 {
     Assert.Throws <FormatException>(() => Holding.CopyNumberFromBarcode("QA234"));
 }
예제 #4
0
        // 1/19/2017: who wrote this?
        //
        // FIXME. Fix this mess. We just have to SHIP IT for nwo!!!
        public void AcceptBarcode(string bc)
        {
            var cl = Holding.ClassificationFromBarcode(bc);
            var cn = Holding.CopyNumberFromBarcode(bc);
            var h  = holdingsService.FindByBarcode(bc);

            if (h.IsCheckedOut)
            {
                if (cur == NoPatron)
                {
                    // ci
                    bc = h.Barcode;
                    var      patronId = h.HeldByPatronId;
                    var      cis      = TimeService.Now;
                    Material m        = null;
                    m = classificationService.Retrieve(h.Classification);
                    var    fine = m.CheckoutPolicy.FineAmount(h.CheckOutTimestamp.Value, cis);
                    Patron p    = patronsService.FindById(patronId);
                    p.Fine(fine);
                    patronsService.Update(p);
                    h.CheckIn(cis, brId);
                    holdingsService.Update(h);
                }
                else
                {
                    if (h.HeldByPatronId != cur) // check out book already cked-out
                    {
                        var bc1 = h.Barcode;
                        var n   = TimeService.Now;
                        var t   = TimeService.Now.AddDays(21);
                        var f   = classificationService.Retrieve(h.Classification).CheckoutPolicy
                                  .FineAmount(h.CheckOutTimestamp.Value, n);
                        var patron = patronsService.FindById(h.HeldByPatronId);
                        patron.Fine(f);
                        patronsService.Update(patron);
                        h.CheckIn(n, brId);
                        holdingsService.Update(h);
                        // co
                        h.CheckOut(n, cur, CheckoutPolicies.BookCheckoutPolicy);
                        holdingsService.Update(h);
                        // call check out controller(cur, bc1);
                        t.AddDays(1);
                        n = t;
                    }
                    else // not checking out book already cked out by other patron
                    {
                        // otherwise ignore, already checked out by this patron
                    }
                }
            }
            else
            {
                if (cur != NoPatron) // check in book
                {
                    h.CheckOut(cts, cur, CheckoutPolicies.BookCheckoutPolicy);
                    holdingsService.Update(h);
                }
                else
                {
                    throw new CheckoutException();
                }
            }
        }
예제 #5
0
 public static Holding FindByBarcode(IRepository <Holding> repo, string barcode)
 {
     return(FindByClassificationAndCopy(repo, Holding.ClassificationFromBarcode(barcode), Holding.CopyNumberFromBarcode(barcode)));
 }