protected CurdAppServiceOfTPrimaryKey(IRepository <TEntity, int> repository,
                                       IObjectMapper objectMapper,
                                       IGetAll <TEntity, int> getAll) : base(
         repository, objectMapper)
 {
     _getAll = getAll;
 }
 public List <GetDelaysAPI.Connection> GetConnection(string dep, string arr)
 {
     if (dep != null && arr != null)
     {
         if (dep != "" && arr != "")
         {
             DateTime now = DateTime.UtcNow;
             now = now.AddHours(2);
             IGetAll           newaccessapi             = SNCBAPI.GetAll.Instance();
             DataApiConnection s                        = newaccessapi.GetConnection(dep, arr);
             List <GetDelaysAPI.Connection> connections = new List <GetDelaysAPI.Connection>();
             foreach (SNCBAPI.Connection c in s.connection)
             {
                 DateTime hourConnection = new DateTime();
                 hourConnection = hourConnection.AddHours(2);
                 hourConnection = hourConnection.AddSeconds(c.departure.time);
                 hourConnection = hourConnection.AddMinutes(c.departure.delay);
                 if (now.TimeOfDay < hourConnection.TimeOfDay)
                 {
                     GetDelaysAPI.Connection co = new GetDelaysAPI.Connection();
                     co.arrival.delay     = c.arrival.delay;
                     co.arrival.station   = c.arrival.station;
                     co.arrival.time      = c.arrival.time.ToString();
                     co.arrival.vehicle   = c.arrival.vehicle;
                     co.departure.delay   = c.departure.delay;
                     co.departure.station = c.departure.station;
                     co.departure.time    = c.departure.time.ToString();
                     co.departure.vehicle = c.departure.vehicle;
                     co.duration          = c.duration;
                     if (c.vias != null)
                     {
                         foreach (SNCBAPI.ViaInfo via in c.vias.via)
                         {
                             GetDelaysAPI.Via v = new GetDelaysAPI.Via();
                             v.arrival.delay     = via.arrival.delay;
                             v.arrival.station   = via.arrival.direction.name;
                             v.arrival.time      = via.arrival.time.ToString();
                             v.arrival.vehicle   = via.arrival.vehicule;
                             v.departure.delay   = via.departure.delay;
                             v.departure.station = via.departure.direction.name;
                             v.departure.time    = via.departure.time.ToString();
                             v.departure.vehicle = via.departure.vehicule;
                             co.vias.Add(v);
                         }
                     }
                     connections.Add(co);
                 }
             }
             return(connections);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
Exemple #3
0
 public Repository(IGetById getter, IGetAll allGetter, ISave saver, IDelete deleter)
 {
     this.getter    = getter;
     this.allGetter = allGetter;
     this.saver     = saver;
     this.deleter   = deleter;
 }
 public GetDelaysAPI.Station GetStationsByName(string station)
 {
     if (station != null)
     {
         DateTime now = DateTime.UtcNow;
         now = now.AddHours(2);
         IGetAPIGoogle        googleApi    = new SearchPlaceAPI();
         IGetAll              newaccessapi = SNCBAPI.GetAll.Instance();
         DataApiPerStations   s            = newaccessapi.GetDelaysForStation(station);
         DetailsPlace         n            = googleApi.GetInfo(string.Concat(s.stationinfo.locationY + "," + s.stationinfo.locationX));
         GetDelaysAPI.Station stat         = new GetDelaysAPI.Station();
         stat.stationinfo.id        = s.stationinfo.id;
         stat.stationinfo.locationX = s.stationinfo.locationX;
         stat.stationinfo.locationY = s.stationinfo.locationY;
         stat.stationinfo.name      = s.stationinfo.name;
         if (n.result.opening_hours != null)
         {
             stat.stationinfo.opening_hours = n.result.opening_hours.weekday_text;
         }
         stat.stationinfo.rating = n.result.rating;
         foreach (GoogleAPI.Review r in n.result.reviews)
         {
             stat.stationinfo.reviews.Add(new GetDelaysAPI.Review {
                 author_name = r.author_name, rating = r.rating, text = r.text
             });
         }
         foreach (SNCBAPI.ArrDep arrdep in s.arrivals.arrival)
         {
             DateTime hourTrain = new DateTime();
             hourTrain = hourTrain.AddHours(2);
             hourTrain = hourTrain.AddSeconds(arrdep.time);
             hourTrain = hourTrain.AddMinutes(arrdep.delay);
             if (now.TimeOfDay < hourTrain.TimeOfDay)
             {
                 stat.arrivals.Add(new ArrivalDeparture {
                     delay = arrdep.delay, id = arrdep.id, station = arrdep.station, time = arrdep.time.ToString(), vehicle = arrdep.vehicle
                 });
             }
         }
         foreach (SNCBAPI.ArrDep arrdep in s.departures.departure)
         {
             DateTime hourTrain = new DateTime();
             hourTrain = hourTrain.AddHours(2);
             hourTrain = hourTrain.AddSeconds(arrdep.time);
             hourTrain = hourTrain.AddMinutes(arrdep.delay);
             if (now.TimeOfDay < hourTrain.TimeOfDay)
             {
                 stat.departures.Add(new ArrivalDeparture {
                     delay = arrdep.delay, id = arrdep.id, station = arrdep.station, time = arrdep.time.ToString(), vehicle = arrdep.vehicle
                 });
             }
         }
         return(stat);
     }
     else
     {
         return(null);
     }
 }
Exemple #5
0
        public List <NotificationConnection> GetNotificationConnections(string userid)
        {
            IUser userDAL = new DALUser();

            api.getdelays.POCO.User       u     = userDAL.GetUser(Convert.ToInt32(userid));
            List <NotificationConnection> listS = new List <NotificationConnection>();
            IGetAll  newaccessapi = SNCBAPI.GetAll.Instance();
            DateTime now          = DateTime.UtcNow;

            now = now.AddHours(2);
            if (u != null)
            {
                foreach (api.getdelays.POCO.FollowedConnection s in u.followedConnections)
                {
                    DataApiConnection stat = newaccessapi.GetConnection(s.departure, s.arrival, s.DateTime);
                    foreach (SNCBAPI.Connection c in stat.connection)
                    {
                        DateTime hourTrain = new DateTime();
                        hourTrain = hourTrain.AddHours(2);
                        hourTrain = hourTrain.AddSeconds(c.departure.time);
                        int year = DateTime.Now.Year - hourTrain.Year;
                        hourTrain = hourTrain.AddYears(year);
                        if (s.DateTime.TimeOfDay == hourTrain.TimeOfDay)
                        {
                            hourTrain = hourTrain.AddMinutes(c.departure.delay);
                            if (hourTrain.TimeOfDay > now.TimeOfDay)
                            {
                                hourTrain = hourTrain.AddMinutes(-c.departure.delay);
                                if (c.departure.delay >= 15 && c.departure.delay < 30)
                                {
                                    listS.Add(new NotificationConnection {
                                        Arrival = s.arrival, Departure = s.departure, DelaysArrival = Convert.ToInt32(c.arrival.delay), DelaysDeparture = Convert.ToInt32(c.departure.delay), Time = hourTrain, Priority = "warning"
                                    });
                                }
                                else if (c.departure.delay < 15 && c.departure.delay >= 0)
                                {
                                    listS.Add(new NotificationConnection {
                                        Arrival = s.arrival, Departure = s.departure, DelaysArrival = Convert.ToInt32(c.arrival.delay), DelaysDeparture = Convert.ToInt32(c.departure.delay), Time = hourTrain, Priority = "normal"
                                    });
                                }
                                else if (c.departure.delay >= 30)
                                {
                                    listS.Add(new NotificationConnection {
                                        Arrival = s.arrival, Departure = s.departure, DelaysArrival = Convert.ToInt32(c.arrival.delay), DelaysDeparture = Convert.ToInt32(c.departure.delay), Priority = "danger"
                                    });
                                }
                            }
                        }
                    }
                }
                return(listS);
            }
            else
            {
                return(null);
            }
        }
 public HomePageViewModel(INavigationService navigationService, IGetAll <Video> getAllVideoRepo)
     : base(navigationService)
 {
     this._navigationService = navigationService;
     this._getAllVideoRepo   = getAllVideoRepo;
     Title        = "Home";
     Videos       = _getAllVideoRepo.GetAll();
     IsDarkModeOn = (App.Current.Resources.Source.OriginalString == "Themes/DarkTheme.xaml");
 }
Exemple #7
0
        public Module(
            IGetAll <Model> allHandler,
            IGetById <Model> idHandler,
            IOptions <Routes> routes)
            : base(routes.Value.Base)
        {
            this.Get("/", allHandler.GetAll);

            this.Get("/{id:int}", idHandler.GetById);
        }
        public void Handle_Is_NOP_Without_Enough_Inventory(TicketsPurchasedUpdateInventoryHandler sut,
            IGetAll<Ticket> ticketGetter, IDelete<Ticket> ticketDeleter,
            ICreate<Order> orderCreator)
        {
            sut.Handle(new TicketsPurchasedEvent(TestData.TicketId,
                TestData.EventId, TestData.TenMoreThanTotalNumberOfTickets));

            ticketGetter.Received(1).All();
            ticketDeleter.DidNotReceive().Delete(Arg.Any<Ticket>());
            orderCreator.DidNotReceive().Create(Arg.Any<Order>());
        }
        public IEnumerable <StationData> SearchStation()
        {
            IGetAll newaccessapi            = SNCBAPI.GetAll.Instance();
            List <SNCBAPI.Station> stations = newaccessapi.GetStations();
            List <StationData>     stats    = new List <StationData>();

            foreach (SNCBAPI.Station s in stations)
            {
                stats.Add(new StationData {
                    name = s.name, locationX = s.locationX, locationY = s.locationY, id = s.id
                });
            }
            return(stats);
        }
Exemple #10
0
        public Train GetTrainFromStation(string idTrain, string StationName)
        {
            IGetAll      newaccessapi = SNCBAPI.GetAll.Instance();
            DataApiTrain s            = newaccessapi.GetTrain(idTrain, StationName);
            Train        train        = new Train();

            train.vehicle = s.vehicle;
            foreach (SNCBAPI.Stop st in s.stops.stop)
            {
                train.stops.Add(new GetDelaysAPI.Stop {
                    delay = st.delay, id = st.id, station = st.station, platform = st.platform, time = st.tForView
                });
            }
            return(train);
        }
Exemple #11
0
        public List <NotificationStation> GetNotificationStations(string userid)
        {
            IUser userDAL = new DALUser();

            api.getdelays.POCO.User    u     = userDAL.GetUser(Convert.ToInt32(userid));
            List <NotificationStation> listS = new List <NotificationStation>();
            IGetAll  newaccessapi            = SNCBAPI.GetAll.Instance();
            DateTime now = DateTime.UtcNow;

            now = now.AddHours(2);
            if (u != null)
            {
                foreach (api.getdelays.POCO.FollowedStation s in u.followedStations)
                {
                    int delays = 0;
                    DataApiPerStations stat = newaccessapi.GetDelaysForStation(s.stationName);
                    foreach (SNCBAPI.ArrDep arrdep in stat.arrivals.arrival)
                    {
                        DateTime hourTrain = new DateTime();
                        hourTrain = hourTrain.AddHours(2);
                        hourTrain = hourTrain.AddSeconds(arrdep.time);
                        hourTrain = hourTrain.AddMinutes(arrdep.delay);
                        if (now.TimeOfDay < hourTrain.TimeOfDay)
                        {
                            delays += arrdep.delay;
                        }
                    }
                    foreach (SNCBAPI.ArrDep arrdep in stat.departures.departure)
                    {
                        DateTime hourTrain = new DateTime();
                        hourTrain = hourTrain.AddHours(2);
                        hourTrain = hourTrain.AddSeconds(arrdep.time);
                        hourTrain = hourTrain.AddMinutes(arrdep.delay);
                        if (now.TimeOfDay < hourTrain.TimeOfDay)
                        {
                            delays += arrdep.delay;
                        }
                    }
                    if (delays >= 15 && delays < 30)
                    {
                        listS.Add(new NotificationStation {
                            StationName = s.stationName, Delays = delays, Priority = "warning"
                        });
                    }
                    else if (delays < 15 && delays > 0)
                    {
                        listS.Add(new NotificationStation {
                            StationName = s.stationName, Delays = delays, Priority = "normal"
                        });
                    }
                    else if (delays >= 30)
                    {
                        listS.Add(new NotificationStation {
                            StationName = s.stationName, Delays = delays, Priority = "danger"
                        });
                    }
                }
                return(listS);
            }
            else
            {
                return(listS);
            }
        }
 public ContactListPageModel(IGetAll <Contact> igetAllContacts)
 {
     this._igetAllContacts = igetAllContacts;
 }
 public GetEntitiesHandler(IGetAll <TEntity> svc)
 {
     _svc = svc;
 }