public IEnumerable <Workorder> LoadUnfilledWorkorders(string part) { using (var context = new WorkorderContext()) { return(context.Workorders .Include(w => w.Parts) .Where(w => w.Parts.Any(p => p.Part == part) && w.FilledUTC == null) .AsNoTracking() .ToList()); } }
public IEnumerable <Workorder> LoadUnfilledWorkorders(int lookaheadDays) { var endDate = DateTime.Today.AddDays(lookaheadDays); using (var context = new WorkorderContext()) { return(context.Workorders .Where(w => w.FilledUTC == null && (lookaheadDays <= 0 || w.DueDate <= endDate)) .Include(w => w.Parts) .AsNoTracking() .ToList()); } }
public void MarkWorkorderAsFilled(string workorderId, DateTime fillUTC, WorkorderResources resources) { using (var context = new WorkorderContext()) { var work = context.Workorders .Include(w => w.Parts) .Single(x => x.WorkorderId == workorderId); if (work != null) { work.FilledUTC = fillUTC; //You will likely also want to store the WorkorderResources somewhere. context.SaveChanges(); } } }