public static List<HouseModel> GetAllHouses()
 {
     using (var db = new SystemDBContext())
     {
         return db.Houses.ToList();
     }
 }
 public List<TestModel> GetTestModel()
 {
     using (var db = new SystemDBContext())
     {
         return db.TestModels.ToList();
     }
 }
 public static void InsertHouseModel(HouseModel model)
 {
     using (var db = new SystemDBContext())
     {
         db.Houses.Add(model);
         db.SaveChanges();
     }
 } 
 private static bool CheckTableExists()
 {
     var context = new SystemDBContext();
     try
     {
         context.Houses.Count();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
        public static void UpdateDatabase(string csv_file_path)
        {
            var data = getCSVContent(csv_file_path);
            var houseModel = GetHouseModel(data);

            using (var db = new SystemDBContext())
            {
                if (!CheckTableExists())
                    return;

                var dbHouses = db.Houses.Select(x => x.Hash).ToList();

                foreach (var house in houseModel.Where(house => !dbHouses.Contains(house.Hash)))
                {
                    db.Houses.Add(house);
                }
                db.SaveChanges();
            }
        }
        public static List<HouseModel> GetHouseNear(HouseLocalizationRequest request)
        {
            using (var db = new SystemDBContext())
            {
                var dbHouses = db.Houses.ToList();
                var result = new List<HouseModel>();

                foreach (var house in dbHouses)
                {
                    if (house.Lat != "" && house.Lon != "")
                    {
                        var deltaLon = double.Parse(house.Lon) - request.lonStart;
                        var deltaLat = double.Parse(house.Lat) - request.latStart;

                        if(Math.Sqrt(Math.Pow(deltaLat,2) + Math.Pow(deltaLon, 2)) <= request.radius)
                            result.Add(house);
                    }
                }
                return result;
            }
        }