예제 #1
0
        public RideVM Post(int id, RideVM vm)
        {
            //update the notes.  This is the only field that is not immutable
            Ride.setNotes(id, vm.notes);

            //return the ride info
            return new RideVM(Ride.getRide(id));
        }
예제 #2
0
        public RideVM Post(RideVM vm)
        {
            //re-calculate the reward and distance
            double rideLength;
            decimal reward;
            Rider rider;

            if (vm.route_id == Route.DefaultId)
            {
                rideLength = vm.distance;
            }
            else
            {
                rideLength = Route.getRoute(vm.route_id).distance;
                if (vm.returnRide)
                {
                    rideLength *= 2;
                }
            }

            rider = Rider.getRider(vm.rider_id);

            reward = vm.payable ? vm.bonus + (decimal)((rideLength * rider.rate) / 100) : 0m;

            //create the ride
            Ride ride = Ride.add(
                vm.bike_id, 
                vm.rider_id, 
                vm.route_id,
                vm.ride_date,
                vm.notes,
                Math.Round(reward, 2),
                Math.Round(rideLength, 1));

            //return the new ride as a view model
            return new RideVM(ride);
        }