Exemplo n.º 1
0
        public void CleanStorage()
        {
            KeepTracking(Trace_StorageCleaning);

            using (CourtDBContext dbContext = new CourtDBContext())
            {
                dbContext.BulkDelete(dbContext.CourtRegions);
            }
        }
Exemplo n.º 2
0
        private void InsertAllLocations(Dictionary <string, CourtDistrict> districtsSaved, IEnumerable <IChangeableData> districtsRaw)
        {
            KeepTracking(Trace_SaveLocations);

            List <CourtLocation> locationsToSave = SetParentIdToLocations(districtsSaved, districtsRaw);

            using (CourtDBContext dbContext = new CourtDBContext())
                dbContext.BulkInsert(locationsToSave);
        }
Exemplo n.º 3
0
        private void InsertAllRegions(IEnumerable <IChangeableData> regionsRaw)
        {
            KeepTracking(Trace_SaveRegions);

            Dictionary <string, CourtRegion> regionDictionary = null;
            CourtDBContext dbContext = new CourtDBContext();

            using (dbContext)
            {
                dbContext.BulkInsert(regionsRaw.Cast <CourtRegion>());
                regionDictionary = dbContext.CourtRegions.ToDictionary(x => x.Name);
            }
            InsertAllDistricts(regionDictionary, regionsRaw);
        }
Exemplo n.º 4
0
        private void InsertAllDistricts(Dictionary <string, CourtRegion> regionsSaved, IEnumerable <IChangeableData> regionsRaw)
        {
            KeepTracking(Trace_SaveDistricts);

            List <CourtDistrict> districtsWithParentId = SetParentIdToDistricts(regionsSaved, regionsRaw);

            Dictionary <string, CourtDistrict> savedDistricts = null;

            using (CourtDBContext dbContext = new CourtDBContext())
            {
                dbContext.BulkInsert(districtsWithParentId);
                savedDistricts = dbContext.CourtDistricts.ToDictionary(x => logger.WarnFormat(Warn_DuplicatedDataFound, x.Name, x.Value));
            }
            InsertAllLocations(savedDistricts, districtsWithParentId);
        }
Exemplo n.º 5
0
        public IEnumerable <IChangeableData> GetData()
        {
            KeepTracking(Trace_AllCurtRegionsLoad);

            using (CourtDBContext dbContext = new CourtDBContext())
            {
                logger.InfoFormat(Trace_GetDbData,
                                  dbContext.Database.Connection.Database,
                                  dbContext.Database.Connection.DataSource);

                return(dbContext.CourtRegions.Include("CourtDistricts")
                       .Include("CourtDistricts.CourtLocations")
                       .ToList());
            }
        }