Пример #1
0
        public void DeletePerson(string name)
        {
            var person = _context.Query <Person>().FirstOrDefault(x => x.Name == name);

            if (person == null)
            {
                return;
            }

            foreach (var child in _context.Query <Person>().Where(x => x.FatherName == name))
            {
                child.FatherName = null;
                _context.Store(child);
            }

            foreach (var child in _context.Query <Person>().Where(x => x.MotherName == name))
            {
                child.MotherName = null;
                _context.Store(child);
            }

            foreach (var parent in _context.Query <Person>(x => x.Children?.Contains(name) ?? false))
            {
                parent.Children.Remove(name);
                _context.Store(parent.Children);
            }

            _context.Delete(person);
            _context.Commit();
        }
Пример #2
0
        public void Delete(object entity)
        {
            if (_db == null)
            {
                BeginTransaction();
            }

            _db.Delete(entity);
        }
Пример #3
0
        public static void DeleteByExample(this IEmbeddedObjectContainer db, object template)
        {
            var result = db.QueryByExample(template);

            foreach (var r in result)
            {
                db.Delete(r);
            }
        }
Пример #4
0
        public static void Delete <T>(this IEmbeddedObjectContainer db, Type t)
        {
            var result = db.Query <T>(t);

            foreach (var r in result)
            {
                db.Delete(r);
            }
        }
Пример #5
0
        public void Delete(IEntity entity)
        {
            var uuid = _container.Ext().GetID(entity);

            if (uuid <= 0)
            {
                var extEntity = entity;
                entity = _container.AsQueryable <IEntity>().FirstOrDefault(e => e.Id == extEntity.Id);
                if (entity == null)
                {
                    throw new NovaromaException(string.Format(Resources.EntityNotFoundInDb, extEntity.Id));
                }
            }

            _container.Delete(entity);
        }
Пример #6
0
        public void Save(List <ReportedCarInfo> newCarInfos, List <ReportedCarInfo> removedInfos)
        {
            var oldInfos = _db4oContainer.Query <ReportedCarInfo>();

            foreach (var item in removedInfos)
            {
                _db4oContainer.Delete(item);
            }

            foreach (var newCarInfo in newCarInfos)
            {
                _db4oContainer.Store(newCarInfo);
            }

            _db4oContainer.Commit();
            _isDirty = true;
        }
Пример #7
0
        private static void LoadRoutes(IEmbeddedObjectContainer cache, FirefoxDriver driver)
        {
            foreach (var route in cache.AsQueryable <Route>())
            {
                cache.Delete(route);
            }

            driver.Url = "http://www.ryanair.com/en";
            driver.ExecuteScript("window.moveTo(0, 0); window.resizeTo(1280, 1024);");
            var fromPicker = new FromPicker(driver);
            var toPicker   = new ToPicker(driver);

            foreach (var fromCode in fromPicker.GetAirportCodes().ToArray())
            {
                fromPicker.PickAirportByCode(fromCode);

                foreach (var toCode in toPicker.GetAirportCodes().ToArray())
                {
                    var route = new Route(fromCode, toCode);
                    Console.WriteLine(route);
                    cache.Store(route);
                }
            }
        }
Пример #8
0
 public void DeleteAll()
 {
     db.Delete <ImageInfo> (typeof(ImageInfo));
     db.Commit();
 }
Пример #9
0
        private static void LoadFlights(IEmbeddedObjectContainer cache, Route route, FirefoxDriver driver, DateTime when, int weeks)
        {
            var fromFlights = cache.AsQueryable <Flight>()
                              .Where(flight => flight.Source == route.Source && flight.Target == route.Target);

            foreach (var flight in fromFlights)
            {
                cache.Delete(flight);
            }

            var toFlights = cache.AsQueryable <Flight>()
                            .Where(flight => flight.Source == route.Target && flight.Target == route.Source);

            foreach (var flight in toFlights)
            {
                cache.Delete(flight);
            }

            driver.Url = "http://www.ryanair.com/en";
            driver.ExecuteScript("window.moveTo(0, 0); window.resizeTo(1280, 1024);");
            var fromPicker = new FromPicker(driver);
            var toPicker   = new ToPicker(driver);
            var search     = new Search(driver);

            fromPicker.PickAirportByCode(route.Source);
            toPicker.PickAirportByCode(route.Target);
            fromPicker.PickWhen(when);
            toPicker.PickWhen(when);
            search.Submit();

            var fromPlanner = new FromPlanner(driver);
            var toPlanner   = new ToPlanner(driver);

            foreach (var week in Enumerable.Range(1, weeks))
            {
                if (FromPlanner.Exists(driver))
                {
                    foreach (var info in fromPlanner.GetInfos())
                    {
                        var flight = new Flight(route.Source, route.Target, info);
                        Console.WriteLine(flight);
                        cache.Store(flight);
                    }
                }

                if (ToPlanner.Exists(driver))
                {
                    foreach (var info in toPlanner.GetInfos())
                    {
                        var flight = new Flight(route.Target, route.Source, info);
                        Console.WriteLine(flight);
                        cache.Store(flight);
                    }
                }

                if (week < weeks && FromPlanner.Exists(driver) && ToPlanner.Exists(driver))
                {
                    toPlanner.ShowNextWeek();
                    fromPlanner.ShowNextWeek();
                }
            }
        }
Пример #10
0
 public async Task Delete <T>(T entity)
 {
     await Task.Run(() => Container.Delete(entity));
 }