Ejemplo n.º 1
0
        public RideVM(Ride ride)
            : this()
        {
            id = ride.id;

            bike_id = ride.bike_id;
            rider_id = ride.rider_id;
            route_id = ride.route_id;

            bike = ride.bike;
            rider = ride.rider;
            route = ride.route;

            distance = Math.Round(ride.distance, 2);
            reward = Math.Round(ride.reward, 2);
            notes = ride.notes;
            ride_date = ride.ride_date;
        }
Ejemplo n.º 2
0
        public static Ride add(
                        int bike_id,
                        int rider_id,
                        int route_id,
                        DateTime ride_date,
                        String notes,
                        decimal reward,
                        double distance)
        {
            Ride ride = new Ride();

            ride.bike_id = bike_id;
            ride.rider_id = rider_id;
            ride.route_id = route_id;
            
            //if no names supplied then look up from ids
            ride.bike = Bike.getBike(bike_id).name;
            ride.rider = Rider.getRider(rider_id).name;
            ride.route = Route.getRoute(route_id).name;
            ride.ride_date = ride_date;

            ride.notes = notes;
            ride.distance = distance;
            ride.reward = reward;

            ride.paid = false;

            using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
            {
                db.Insert(ride);
            }
            return ride;
        }