public async Task <IHttpActionResult> buyBulkVoucher(int userID, decimal BulkVoucherAmount) { if (isUserReseller(userID)) { //need to check if reseller has the available funds in bank account - else return bad request or err page //transfer money from reseller bank account to nanoFin account voucher newVoucher = new voucher(); newVoucher.User_ID = userID; newVoucher.voucherValue = BulkVoucherAmount; newVoucher.VoucherType_ID = 1; newVoucher.voucherCreationDate = DateTime.Now; db.vouchers.Add(newVoucher); db.SaveChanges(); addVoucherTransaction(newVoucher.Voucher_ID, newVoucher.Voucher_ID, userID, 1, BulkVoucherAmount, 1); //buy bulk transaction on blockchain MResellerController resellerCtrl = new MResellerController(userID); resellerCtrl = await resellerCtrl.init(); await resellerCtrl.buyBulk(Decimal.ToInt32(BulkVoucherAmount)); return(Ok()); } else { return(BadRequest("User not a valid reseller")); } }
public async Task <bool> resellerBuyBulk(int userID, int amount) { MResellerController resellerCtrl = new MResellerController(userID); resellerCtrl = await resellerCtrl.init(); await resellerCtrl.buyBulk(Decimal.ToInt32(amount)); return(true); }