Ejemplo n.º 1
0
 public BookingLine()
 {
     station = new Station();
     BatteryType = new BatteryType();
 }
Ejemplo n.º 2
0
        public Station getStation(int id)
        {
            StationCtr sCtr = new StationCtr();
            MStation s = null;
            try
            {
                s = sCtr.getStation(id, false);
            }
            catch (NullReferenceException)
            {
            }

            Station ns = new Station();
            if (s != null)
            {
                ns.Id = s.Id;
                ns.Name = s.name;
                ns.State = s.state.ToString();
                ns.Country = s.country;
                ns.Address = s.address;
            }

            return ns;
        }
Ejemplo n.º 3
0
        public List<List<RouteStop>> getRoutes(int startSId, int endSIdint, DateTime tripStart, decimal batteryLimit)
        {
            List<List<RouteStop>> paths = new List<List<RouteStop>>();
            List<List<PathStop>> routes = new List<List<PathStop>>();
            PathFindCtr pfCtr = new PathFindCtr();
            routes = pfCtr.findRoutes(startSId, endSIdint, tripStart, batteryLimit);
            if (routes != null)
            {
                foreach (List<PathStop> r in routes)
                {
                    List<RouteStop> x = new List<RouteStop>();
                    for (int i = 0; i < r.Count; i++)
                    {
                        //translate path to route
                        RouteStop rs = new RouteStop();
                        rs.stationID = r[i].stationID;
                        Station s = new Station();
                        s.Id = r[i].station.Id;
                        s.Name = r[i].station.name;
                        s.Address = r[i].station.address;
                        rs.station = s;
                        if (i != 0)
                        {
                            rs.distance = r[i].distance + x[i - 1].distance;
                            rs.driveHour = r[i].driveHour + x[i - 1].driveHour;
                            rs.time = tripStart.AddHours(Convert.ToDouble(rs.driveHour));
                        }
                        else
                        {
                            rs.distance = r[i].distance;
                            rs.driveHour = r[i].driveHour;
                            rs.time = tripStart;
                        }
                        x.Add(rs);
                    }
                    paths.Add(x);
                }
            }

            return paths;
        }
Ejemplo n.º 4
0
        public Booking getBooking(int id)
        {
            Booking bk = new Booking();
            BookingCtr bCtr = new BookingCtr();
            MBooking b = bCtr.getBooking(id, true);
            if (bk != null)
            {
                foreach (MBookingLine bl in b.bookinglines)
                {
                    BookingLine l = new BookingLine();
                    l.price = bl.price.Value;
                    l.quantity = bl.quantity.Value;
                    l.time = bl.time.Value;
                    bk.bookinglines.Add(l);

                    BatteryType bt = new BatteryType();
                    bt.ID = bl.BatteryType.id;
                    bt.name = bl.BatteryType.name;
                    l.BatteryType = bt;

                    Station s = new Station();
                    s.Id = bl.Station.Id;
                    s.Name = bl.Station.name;
                    s.Address = bl.Station.address;
                    s.Country = bl.Station.country;
                    l.station = s;

                }
                bk.startStationId = b.bookinglines.First().Station.Id;
            }
            return bk;
        }
Ejemplo n.º 5
0
        public List<Station> getAllStations()
        {
            using (StationCtr sCtr = new StationCtr())
            {
                List<Station> ss = new List<Station>();
                List<MStation> stations = sCtr.getAllStation();
                foreach (MStation item in stations)
                {
                    Station s = new Station() { Id = item.Id, Name = item.name, Address = item.address, Country = item.country, State = item.state.ToString() };
                    ss.Add(s);

                }
                return ss;
            }
        }
Ejemplo n.º 6
0
        public List<Booking> getAllBookings()
        {
            List<Booking> bookings = new List<Booking>();
            BookingCtr bCtr = new BookingCtr();
            List<MBooking> bs = bCtr.getAllBooking();
            if (bs.Count != 0)
            {
                foreach (MBooking b in bs)
                {
                    Booking bk = new Booking();
                    bk.Id = b.Id;
                    bk.createDate = b.createDate.Value.ToString("dd/MM/yyyy");
                    Customer cust = new Customer() { ID = b.customer.ID, name = b.customer.FName + " " + b.customer.LName };
                    bk.customer = cust;
                    bk.cId = b.customer.ID;
                    bk.payStatus = b.creaditCard;
                    bk.totalPrice = b.totalPrice.Value;
                    bk.tripStart = b.tripStart.Value.ToString("dd/MM/yyyy HH:mm");
                    if (b.bookinglines.Count != 0)
                    {
                        foreach (MBookingLine bl in b.bookinglines)
                        {
                            BookingLine l = new BookingLine();
                            l.price = bl.price.Value;
                            l.quantity = bl.quantity.Value;
                            l.time = bl.time.Value;
                            bk.bookinglines.Add(l);
                            BatteryType bt = new BatteryType();
                            bt.ID = bl.BatteryType.id;
                            bt.name = bl.BatteryType.name;
                            l.BatteryType = bt;
                            Station s = new Station();
                            s.Id = bl.Station.Id;
                            s.Name = bl.Station.name;
                            s.Address = bl.Station.address;
                            s.Country = bl.Station.country;
                            l.station = s;

                        }
                        bk.startStationId = b.bookinglines.First().Station.Id;
                    }
                    bookings.Add(bk);
                }
            }

            return bookings;
        }