Exemple #1
0
 public void addBooking(Booking b)
 {
     MBooking bk = new MBooking();
     bk.cId = b.cId;
     bk.createDate = DateTime.ParseExact(b.createDate, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture);
     bk.creaditCard = b.payStatus;
     bk.tripStart = DateTime.ParseExact(b.tripStart, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.CurrentCulture);
     bk.totalPrice = b.totalPrice;
     List<MBookingLine> bkls = new List<MBookingLine>();
     List<BookingLine> bls = b.bookinglines.ToList<BookingLine>();
     for (int i = 0; i < bls.Count; i++)
     {
         MBookingLine bl = new MBookingLine();
         bl.price = bls[i].price;
         bl.quantity = bls[i].quantity;
         bl.Station.Id = bls[i].station.Id;
         bl.time = bls[i].time;
         bl.BatteryType.id = bls[i].BatteryType.ID;
         bkls.Add(bl);
     }
     bk.bookinglines = bkls;
     BookingCtr bCtr = new BookingCtr();
     if (!bCtr.addBooking(bk))
     {
         FaultException f = new FaultException("Booking failed because one of the station is fully booked");
         throw f;
     }
 }
Exemple #2
0
 public void updateBooking(Booking b)
 {
     MBooking bk = new MBooking();
     bk.Id = b.Id;
     bk.cId = b.cId;
     bk.createDate = Convert.ToDateTime(b.createDate);
     bk.creaditCard = b.payStatus;
     bk.totalPrice = b.totalPrice;
     bk.tripStart = DateTime.ParseExact(b.createDate, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture);
     bk.tripStart = DateTime.ParseExact(b.tripStart, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.CurrentCulture);
     BookingCtr bCtr = new BookingCtr();
     bCtr.updateBooking(bk);
 }
Exemple #3
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;
        }
Exemple #4
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;
        }