Example #1
0
        public List <Signal> GetSignalsBetweenDates(string signalId, DateTime startDate, DateTime endDate)
        {
            List <Common.Models.Signal> signals = new List <Signal>();

            Common.Models.Signal signalBeforeStart = _db.Signals

                                                     .Where(signal => signal.SignalID == signalId &&
                                                            signal.Start <= startDate &&
                                                            signal.VersionActionId != 3).OrderByDescending(s => s.Start)
                                                     .Take(1)
                                                     .FirstOrDefault();
            if (signalBeforeStart != null)
            {
                signals.Add(signalBeforeStart);
            }
            if (_db.Signals.Any(signal => signal.SignalID == signalId &&
                                signal.Start > startDate &&
                                signal.Start < endDate &&
                                signal.VersionActionId != 3))
            {
                signals.AddRange(_db.Signals

                                 .Where(signal => signal.SignalID == signalId &&
                                        signal.Start > startDate &&
                                        signal.Start < endDate &&
                                        signal.VersionActionId != 3).ToList());
            }
            return(signals);
        }
Example #2
0
 public void AddOrUpdate(Common.Models.Signal signal)
 {
     MOE.Common.Models.Signal g = (from r in _db.Signals
                                   where r.SignalID == signal.SignalID
                                   select r).FirstOrDefault();
     if (g == null)
     {
         _db.Signals.Add(signal);
     }
     else
     {
         Update(signal);
     }
 }