Esempio n. 1
0
        public List <DeptorsReadersModel> GetDebtorsReaders(int?minDays, int?maxDays)
        {
            DeptorsReadersMapper       deptorsReadersMapper   = new DeptorsReadersMapper();
            List <DeptorsReadersModel> deptorsReadersBusiness = new List <DeptorsReadersModel>();

            List <ReaderHistory> readerHistory;

            if ((minDays != 0 && maxDays != 0) && (minDays != null && maxDays != null))
            {
                DateTime min = DateTime.Now.AddDays((double)-minDays);
                DateTime max = DateTime.Now.AddDays((double)-maxDays);

                readerHistory = this.uow.ReadersHistories.GetAll().Where(r => r.FinishDate < DateTime.Now && r.ReturnDate == null &&
                                                                         (r.FinishDate > max && r.FinishDate < min))
                                .Select(r => r).ToList();
            }
            else
            {
                readerHistory = this.uow.ReadersHistories.GetAll().Where(r => r.FinishDate < DateTime.Now && r.ReturnDate == null)
                                .Select(r => r).ToList();
            }

            for (int i = 0; i < readerHistory.Count; i++)
            {
                deptorsReadersBusiness.Add(deptorsReadersMapper.Map(readerHistory[i]));
            }

            return(deptorsReadersBusiness);
        }
        public void DebtorsEntityToModelMappingTest()
        {
            var result = debtorsReadersMapper.Map(this.readerHistoryEntityToMap);

            Assert.AreEqual(this.deptorsReadersModelToCompareWith.readerId, result.readerId);
            Assert.AreEqual(this.deptorsReadersModelToCompareWith.FirstName, result.FirstName);
            Assert.AreEqual(this.deptorsReadersModelToCompareWith.LastName, result.LastName);
            Assert.AreEqual(this.deptorsReadersModelToCompareWith.Address, result.Address);
            Assert.AreEqual(this.deptorsReadersModelToCompareWith.Phone, result.Phone);
            Assert.AreEqual(this.deptorsReadersModelToCompareWith.StartDate, result.StartDate);
            Assert.AreEqual(this.deptorsReadersModelToCompareWith.FinishDate, result.FinishDate);
        }