public OffenderNewLocationWorkflow(BloodhoundContext dbContext, long offenderId)
 {
     this.dbContext    = dbContext ?? throw new ArgumentNullException(nameof(offenderId));
     this.offender     = dbContext.Offenders.Find(offenderId) ?? throw new EntityNotFoundException(nameof(Offender), offenderId);
     this.lastLocation = dbContext.OffenderLocations.Where(x => x.OffenderId == this.offender.OffenderId).Take(1).OrderByDescending(x => x.LocationTime).FirstOrDefault();
     this.geoFences    = dbContext.OffenderGeoFences.Where(x => x.OffenderId == this.offender.OffenderId).ToList();
 }
        public void Initialize()
        {
            var configurationBuilder = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            DbContextOptionsBuilder <BloodhoundContext> optionsBuilder = new DbContextOptionsBuilder <BloodhoundContext>();

            optionsBuilder.UseSqlServer(configurationBuilder.GetConnectionString("BloodhoundContext"));
            this.dbContext = new BloodhoundContext(optionsBuilder.Options);
            this.dbContext.Database.EnsureCreated();
            this.dbContext.Database.Migrate();
        }
        public void Initialize(BloodhoundContext dbContext)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            this.Offender = dbContext.Offenders.Find(id);
            if (this.Offender == null)
            {
                throw new EntityNotFoundException(nameof(Offender), this.id);
            }

            this.LastLocation = dbContext.v_OffenderLastLocation.FirstOrDefault(x => x.OffenderId == this.Offender.OffenderId);

            this.GeoFences = dbContext.OffenderGeoFences.Where(x => x.OffenderId == this.Offender.OffenderId).ToList();
        }
 public GeoFencesController(BloodhoundContext context)
 {
     _context = context;
 }
Beispiel #5
0
 public HomeController(BloodhoundContext context)
 {
     _context = context;
 }
 public OffendersController(BloodhoundContext context)
 {
     _context = context;
 }
 public void Cleanup()
 {
     this.dbContext?.Dispose();
     this.dbContext = null;
 }