public bool NeedNewDriverAdvance(IUnitOfWork uow) { if (!_newDriverAdvanceParametersProvider.IsNewDriverAdvanceEnabled || _routeListRepository.HasEmployeeAdvance(uow, _routeList.Id, _routeList.Driver.Id)) { return(false); } DateTime?lastRouteListDate = _routeListRepository.GetLastRouteListDateByDriver(uow, _routeList.Driver.Id, null, CarOwnType.Driver); DateTime?firstAdvanceDate = _routeListRepository.GetDateByDriverWorkingDayNumber(uow, _routeList.Driver.Id, _newDriverAdvanceParametersProvider.NewDriverAdvanceFirstDay, null, CarOwnType.Driver); DateTime?lastAdvanceDate = _routeListRepository.GetDateByDriverWorkingDayNumber(uow, _routeList.Driver.Id, _newDriverAdvanceParametersProvider.NewDriverAdvanceLastDay, null, CarOwnType.Driver); bool needNewDriverAdvance = firstAdvanceDate <= _routeList.Date && _routeList.Date <= (lastAdvanceDate ?? lastRouteListDate); return(needNewDriverAdvance); }