Beispiel #1
0
 public bool Exists(Guid command)
 {
     using (var db = new LogDbContext(DatabaseConnectionString))
     {
         return(db.Commands
                .AsNoTracking()
                .Any(x => x.CommandIdentifier == command));
     }
 }
Beispiel #2
0
 public IEnumerable <Guid> GetExpired(DateTimeOffset at)
 {
     using (var db = new LogDbContext(DatabaseConnectionString))
     {
         return(db.Aggregates
                .AsNoTracking()
                .Where(x => x.AggregateExpires != null && x.AggregateExpires <= at)
                .Select(x => x.AggregateIdentifier)
                .ToList());
     }
 }
Beispiel #3
0
        public IEnumerable <SerializedCommand> GetExpired(DateTimeOffset at)
        {
            using (var db = new LogDbContext(DatabaseConnectionString))
            {
                var commands = db.Commands
                               .AsNoTracking()
                               .Where(x => x.SendScheduled <= at && x.SendStatus == "Scheduled")
                               .ToArray();

                return(commands);
            }
        }
Beispiel #4
0
        public SerializedCommand Get(Guid command)
        {
            using (var db = new LogDbContext(DatabaseConnectionString))
            {
                var entity = db.Commands
                             .AsNoTracking()
                             .Where(x => x.CommandIdentifier == command)
                             .FirstOrDefault();

                return(entity ?? throw new CommandNotFoundException($"Command not found: {command}"));
            }
        }
Beispiel #5
0
 public void Delete(Guid id)
 {
     using (var db = new LogDbContext(DatabaseConnectionString))
     {
         var command = db.Commands.FirstOrDefault(x => x.CommandIdentifier == id);
         if (command != null)
         {
             db.Commands.Remove(command);
             db.SaveChanges();
         }
     }
 }