public long CountProductsPurchasedByInterval(DateTime fromDate, DateTime toDate) { long sum = 0; try { sum = _purchaseBillRepository.GetAll().Where(s => (s.CreatedDate.Year > fromDate.Year || (s.CreatedDate.Year == fromDate.Year && s.CreatedDate.Month > fromDate.Month || (s.CreatedDate.Year == fromDate.Year && s.CreatedDate.Month == fromDate.Month && s.CreatedDate.Day >= fromDate.Day)) ) && (s.CreatedDate.Year < toDate.Year || (s.CreatedDate.Year == toDate.Year && s.CreatedDate.Month < toDate.Month || (s.CreatedDate.Year == toDate.Year && s.CreatedDate.Month == toDate.Month && s.CreatedDate.Day <= toDate.Day)) )).Sum(p => p.PurchaseBillDetails.Sum(pd => (long)pd.Quantity)); } catch (Exception) { //throw; } return(sum); }
public List <PurchaseBill> GetAll() { return(_purchaseBillRepository.GetAll().OrderByDescending(p => p.CreatedDate).ToList()); }