// GET: Patrons/Details/5 public async Task <IActionResult> Details(int id) { var patron = await context.Patrons.FirstByIdAsync(id); if (patron == null) { return(BadRequest()); } var patronView = new PatronViewModel(patron) { Holdings = patronsService.HoldingsForPatron(id) }; return(View(patronView)); }
public void HoldingsPopulatesListOfHoldingsForPatron() { context.Holdings.Add(new Holding { Classification = "AA", HeldByPatronId = 1 }); context.Holdings.Add(new Holding { Classification = "BB", HeldByPatronId = 3 }); context.Holdings.Add(new Holding { Classification = "CC", HeldByPatronId = 5 }); context.Holdings.Add(new Holding { Classification = "DD", HeldByPatronId = 3 }); context.SaveChanges(); var holdings = service.HoldingsForPatron(3); Assert.Collection(holdings, holding => Assert.Equal("BB", holding.Classification), holding => Assert.Equal("DD", holding.Classification)); }