Example #1
0
 public async Task DropDB()
 {
     using (var context = new MssqlContext())
     {
         await context.Database.EnsureDeletedAsync();
     }
 }
Example #2
0
 static async Task <IEnumerable <string> > GetVehicles()
 {
     using (var dbContext = new MssqlContext())
     {
         return(await(from v in dbContext.Vehicles
                      select v.VIN).ToListAsync());
     }
 }
Example #3
0
        public void Store(Hero hero)
        {
            using (var context = new MssqlContext())
            {
                context.Entry(hero).State = ((hero.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
Example #4
0
        public void Remove(Hero hero)
        {
            using (var context = new MssqlContext())
            {
                context.Entry(hero).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
Example #5
0
        public void Add(Hero hero)
        {
            using (var context = new MssqlContext())
            {
                context.Heroes.Add(hero);

                context.SaveChanges();
            }
        }
Example #6
0
        public async Task CreateDB()
        {
            MssqlContext.ConnectionString = ConnectionString;

            using (var context = new MssqlContext())
            {
                await context.Database.EnsureCreatedAsync();
            }
        }
Example #7
0
 public Hero Load(Hero hero)
 {
     if (!Exists(hero))
     {
         throw new Exception($"There's no such hero with ID: {hero.ID}");
     }
     using (var context = new MssqlContext())
     {
         return(context.Heroes.Find(hero.ID));
     }
 }
Example #8
0
        public IList <Hero> GetList()
        {
            using (var context = new MssqlContext())
            {
                var query = from h in context.Heroes
                            select h;

                var heroes = query.ToList <Hero>();
                return(heroes);
            }
        }
Example #9
0
        public IList <User> GetList()
        {
            using (var context = new MssqlContext())
            {
                var querry = from f in context.Users
                             select f;
                var users = querry.ToList <User>();

                return(users);
            }
        }
Example #10
0
        public bool Exists(Hero hero)
        {
            using (var context = new MssqlContext())
            {
                //var query = from h in context.Heroes
                //        where h.Name == hero.Name
                //        select h;

                IQueryable <Hero> query = BuildQuery(context.Heroes, hero);

                var exists = query.Any <Hero>();
                return(exists);
            }
        }
Example #11
0
        public IList <Hero> FindList(Hero hero)
        {
            using (var context = new MssqlContext())
            {
                //var query = from h in context.Heroes
                //        where h.Name == hero.Name
                //        select h;

                IQueryable <Hero> query = BuildQuery(context.Heroes, hero);

                var heroes = query.ToList <Hero>();
                return(heroes);
            }
        }
        public async Task TestVehicleGetsConnectedAfterPing()
        {
            var vehiclesDataIntoDB = TestData.GetVehicles();

            using (var dbContext = new MssqlContext())
            {
                dbContext.Vehicles.AddRange(vehiclesDataIntoDB);
                await dbContext.SaveChangesAsync();
            }

            var vehicleMonitoringService = new VehicleMonitoringService(new VehiclesRepository(), TimeSpan.FromMilliseconds(50));
            await vehicleMonitoringService.Init();

            var apiController = new VehiclesStatusController(vehicleMonitoringService);

            var vehiclesStatusInfo = await apiController.Monitoring();

            Assert.IsTrue(vehiclesStatusInfo.Count() == vehiclesDataIntoDB.Count(), "Count of vehicles in db and returned from api does not match");
        }
Example #13
0
 public PhoneRepository(MssqlContext context) : base(context)
 {
 }
 public SellerRepository(MssqlContext context,
                         UserManager <ApplicationUser> userManager) : base(context)
 {
     _userManager = userManager;
 }
 public ShippingCompanyRepository(MssqlContext context) : base(context)
 {
 }
 public CollegeRepository(MssqlContext context) : base(context)
 {
 }
Example #17
0
 public TypeGenericRepository(MssqlContext context) : base(context)
 {
 }
Example #18
0
 public BaseRepository(MssqlContext context)
 {
     Context = context;
 }
Example #19
0
 public AddressRepository(MssqlContext context) : base(context)
 {
 }