public void Update(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));
                }
                entity.CopyFrom(extEntity);
            }

            entity.IsModified = false;
            _container.Store(entity);
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
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();
                }
            }
        }
Exemple #4
0
 public bool IsNameTaken(string name)
 {
     return(_context.AsQueryable <Person>().Any(x => x.Name == name));
 }
Exemple #5
0
 public IQueryable <T> GetAll <T>()
 {
     return(Container.AsQueryable <T>());
 }