public int CountSaleBillByInterval(DateTime fromDate, DateTime toDate) { var count = 0; count = _saleBillRepository.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)) )).Count(); return(count); }
public bool Add(EndOfShiftViewModel entity) { var endOfShift = entity.MapToEndOfShift(); endOfShift.CreatedDate = DateTime.Now; endOfShift.StaffId = StaffGlobal.CurrentStaff.StaffId; DateTime fromDatetime = new DateTime(endOfShift.CreatedDate.Year, endOfShift.CreatedDate.Month, endOfShift.CreatedDate.Day, entity.From, 0, 0); DateTime toDatetime = new DateTime(endOfShift.CreatedDate.Year, endOfShift.CreatedDate.Month, endOfShift.CreatedDate.Day, entity.To, 0, 0); //hanlder money long totalMoney = 0; try { totalMoney = _saleBillRepository.GetAll().Where(s => !s.IsAprroved && s.StaffId == endOfShift.StaffId && s.CreatedDate >= fromDatetime && s.CreatedDate <= toDatetime) .Sum(s => s.TotalMoney); } catch (Exception) { } endOfShift.TotalMoney = totalMoney; return(_endOfShiftRepository.Add(endOfShift)); }
public List <SaleBill> GetAll() { if (StaffGlobal.CurrentStaff == null) { return(null); } else if (StaffGlobal.CurrentStaff.StaffRole == (int)EStaffRole.Administrator) { return(_saleBillRepository.GetAll().OrderByDescending(s => s.CreatedDate).ToList()); } else { return(_saleBillRepository.FindAll(s => s.StaffId == StaffGlobal.CurrentStaff.StaffId).OrderByDescending(s => s.CreatedDate).ToList()); } }