示例#1
0
 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());
     }
 }
示例#2
0
        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());
            }
        }
示例#3
0
        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();
                }
            }
        }