public bool IsNeedPR(string empId, int days) { Employee emp = GetById(empId); PerformanceReviewDao perDao=new PerformanceReviewDao (); List<PerformanceReview> prList = perDao.GetListByEmployeeId(emp.ID).OrderByDescending(p=>p.CreateDate).ToList(); //Return true if there's no record if (prList.Count == 0) return true; //Return false if there's at least 1 PR in "Open" status bool isOpen = false; foreach (var item in prList) { if (item.WFStatusID == Constants.STATUS_OPEN) { isOpen = true; break; } } if (isOpen) return false; else if( !isOpen && days==0 ) return true; else if (prList.FirstOrDefault().NextReviewDate.HasValue && days != 0) { PerformanceReview pr = prList.FirstOrDefault(); if (pr.NextReviewDate.Value < DateTime.Now) return true; int iNum = pr.NextReviewDate.Value.Subtract(DateTime.Now).Days; if(iNum < 0 || iNum <= days) { return true; } } return false; }