// 1/19/2017: who wrote this? // confusion between service and domain objects. What can push into domain? // With a "real" persistent model, everything would need to go through service, presumably, // to ensure liveness. TODO. We just have to SHIP IT for nwo!!! public void AcceptBarcode(string bc) { var h = holdingService.Retrieve(bc); if (h.IsCheckedOut) { if (cur == NoPatron) { // ci bc = h.Barcode; var patronId = holdingService.Retrieve(bc).HeldByPatronId; var cis = TimeService.Now; Material m = null; m = classificationService.Retrieve(h.Classification); var fine = m.CheckoutPolicy.FineAmount(h.CheckOutTimestamp, cis); var p = patronService.Retrieve(patronId); p.Fine(fine); holdingService.CheckIn(cis, bc, brId); patronService.CheckIn(patronId, bc); } else // checking out book already cked out by other patron { if (h.HeldByPatronId != cur) { var bc1 = h.Barcode; var n = TimeService.Now; var t = TimeService.Now.AddDays(21); var f = classificationService.Retrieve(h.Classification).CheckoutPolicy.FineAmount(h.CheckOutTimestamp, n.AddDays(21)); var patron = patronService.Retrieve(h.HeldByPatronId); patron.Fine(f); holdingService.CheckIn(n, bc1, brId); // co holdingService.CheckOut(cts, bc1, cur, CheckoutPolicies.BookCheckoutPolicy); patronService.CheckOut(cur, bc1); t.AddDays(1); n = t; patronService.CheckIn(patron.Id, bc); } 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 { holdingService.CheckOut(cts, h.Barcode, cur, CheckoutPolicies.BookCheckoutPolicy); patronService.CheckOut(cur, h.Barcode); } else { throw new CheckoutException(); } } }
public static CheckoutPolicy RetrievePolicy(string barcode, IClassificationService classificationService) { var classification = Holding.ClassificationFromBarcode(barcode); var material = classificationService.Retrieve(classification); return(material.CheckoutPolicy); }
public void Persists() { service.AddBook("QA123", "The Trial", "Kafka, Franz", "1927"); service = new MasterClassificationService(); AssertBook(service.Retrieve("QA123"), "QA123", "The Trial", "Kafka, Franz", "1927"); }
private CheckoutPolicy RetrievePolicy(string classification) { var material = classificationService.Retrieve(classification); return(material.CheckoutPolicy); }
// 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(); } } }
public void AddBook() { service.AddBook("QA123", "The Trial", "Kafka, Franz", "1927"); AssertBook(service.Retrieve("QA123"), "QA123", "The Trial", "Kafka, Franz", "1927"); }