public Rider Post(Rider rider) { rider.save(); rider.setPwd(Membership.GeneratePassword(12, 5)); return rider; }
private Payment payRider(IEnumerable<Ride> unpaidRides, Rider rider) { Payment payment = null; IEnumerable<Ride> ridesToPay = unpaidRides.Where(r => r.rider_id == rider.id); decimal total = ridesToPay.Sum(r => r.reward); //if rider has a valid-looking account set up if (total > 0 && rider.bank_branch_id.HasValue && rider.bank_branch_id != Bank.DefaultBranchId && rider.bank_customer_id.HasValue && rider.bank_customer_id != Bank.DefaultCustomerId && rider.bank_account_id.HasValue && rider.bank_account_id != Bank.DefaultAccountId) { //pay into the bank payment = Bank.deposit(rider, total, "Bike mileage payment"); if (payment.success) { //mark each ride as paid foreach (Ride ride in ridesToPay) { ride.setAsPaid(payment.id); } } else { //payment failed //do nothing, don't return a payment record payment = null; } } return payment; }
public Rider Post(int id, Rider rider) { rider.save(); return rider; }