Beispiel #1
0
        public void GetTapeReportAtDate_ReturnsTapesWithId1And2And4And5FromTwoYearsAgo()
        {
            List <int> tapeIdsForTapesOnLoanTwoYearsAgo = new List <int>()
            {
                1, 2, 4, 5
            };
            var tapes = _tapeService.GetTapeReportAtDate(DateTime.Now.AddYears(-2).AddDays(1));

            Assert.AreEqual(tapeIdsForTapesOnLoanTwoYearsAgo.Count, tapes.Count());
            foreach (var tapeId in tapeIdsForTapesOnLoanTwoYearsAgo)
            {
                Assert.IsNotNull(tapes.FirstOrDefault(t => t.Id == tapeId));
            }
        }
Beispiel #2
0
 public IActionResult GetAllTapes([FromQuery] string LoanDate)
 {
     // If no loan date provided as query parameter all tapes are returned
     if (String.IsNullOrEmpty(LoanDate))
     {
         return(Ok(_tapeService.GetAllTapes()));
     }
     // Otherwise return record of all tape borrows on date specified
     // If loan date is an invalid date, throw 400 parameter format exception
     else
     {
         DateTime BorrowDate;
         if (!DateTime.TryParse(LoanDate, out BorrowDate))
         {
             throw new ParameterFormatException("LoanDate");
         }
         return(Ok(_tapeService.GetTapeReportAtDate(BorrowDate)));
     }
 }