public List <Log> GetAllLogItems()
        {
            string          query           = "select * from Log";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <Log>());
        }
Пример #2
0
        public List <Vehicle> GetVehiclesByUserId(string userId)
        {
            string          query           = "select * from Vehicle where UserId='" + userId + "'";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <Vehicle>());
        }
        public bool IsViaPointExists(Ride ride, string viaPoint)
        {
            string          query           = "select Name from ViaPoint where RideId='" + ride.Id + "'";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <string>().Contains(viaPoint));
        }
        public int GetViaPointsCount(Ride ride)
        {
            string          query           = "select * from ViaPoint where RideId='" + ride.Id + "'";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <ViaPoint>().Count());
        }
        public int GetIndex(Ride ride, string viaPoint)
        {
            string          query           = "select Name from ViaPoint where RideId='" + ride.Id + "'";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <string>().IndexOf(viaPoint));
        }
        public List <ViaPoint> GetAllViaPoints(string rideId)
        {
            string          query           = "select * from ViaPoint where RideId='" + rideId + "'";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <ViaPoint>());
        }
Пример #7
0
        public List <VehicleType> GetAllVehicleTypes()
        {
            string          query           = "select * from VehicleType";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            return(extensionObject.GetAllItems <VehicleType>());
        }
        public List <Ride> FindRide(string from, string to)
        {
            from = from.ToLower();
            to   = to.ToLower();
            List <Ride> requiredRides  = new List <Ride>();
            int         availableSeats = 0;

            IBookingService  bookingService  = new BookingService(configuration);
            IViaPointService viaPointService = new ViaPointService(configuration);

            string          query           = "select * from Ride";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };

            List <Ride> rides = extensionObject.GetAllItems <Ride>();

            foreach (Ride ride in rides)
            {
                availableSeats = bookingService.AvailableSeats(ride, from, to);
                if (availableSeats > 0)
                {
                    ride.AvailableSeats = availableSeats;
                    query = "select id,name,phoneNumber from [User] where Id= (select publisherId from Ride where Id='" + ride.Id + "')";
                    ExtensionObject publisherExtensionObject = new ExtensionObject()
                    {
                        Query            = query,
                        ConnectionString = connectionString
                    };

                    ride.Publisher = publisherExtensionObject.GetItem <User>();
                    query          = "select value from Status where Id=(select statusId from Ride where Id='" + ride.Id + "')";
                    ExtensionObject statusExtensionObject = new ExtensionObject()
                    {
                        Query            = query,
                        ConnectionString = connectionString
                    };
                    ride.Status = statusExtensionObject.GetItem <Status>();
                    requiredRides.Add(ride);
                }
            }
            return(requiredRides);
        }
        public int GetBookingsCount(string rideId, string from, string to)
        {
            string query = "select NumberOfSeatsBooked from Booking where StatusId in (select Id from Status where Type='Booking' and Value='Approved') and RideId='" + rideId +
                           "' and PickUp='" + from + "' and [Drop]='" + to + "'";
            ExtensionObject extensionObject = new ExtensionObject()
            {
                Query            = query,
                ConnectionString = connectionString
            };
            List <Booking> approvedBookings = extensionObject.GetAllItems <Booking>();

            int count = 0;

            if (approvedBookings == null)
            {
                return(count);
            }
            foreach (Booking booking in approvedBookings)
            {
                count += booking.NumberOfSeatsBooked;
            }
            return(count);
        }