public async Task <IHttpActionResult> consumerSendVoucher_RecipientUnknown(int consumerUserID, string recipientDetails, decimal transferAmount) { if (isUserConsumer(consumerUserID)) { int recipientUserID = getUserDetailsToUserID(recipientDetails); if (isUserConsumer(recipientUserID)) { SendVoucher(consumerUserID, recipientUserID, transferAmount, 21, 2); MConsumerController consumerCtrl = new MConsumerController(consumerUserID); consumerCtrl = await consumerCtrl.init(); await consumerCtrl.sendVoucherToConsumer(recipientUserID, Decimal.ToInt32(transferAmount)); return(Ok()); } else { return(BadRequest("Receiver is not a consumer")); } } else { return(BadRequest("Sender is not a consumer")); } }
public async Task <IHttpActionResult> consumerSendVoucher(int consumerUserID, int recipientID, decimal transferAmount) { if (isUserConsumer(consumerUserID) && isUserConsumer(recipientID)) { if (recipientID > 0) { if (getVoucherAccountBalance(consumerUserID) < transferAmount) { return(BadRequest("invalid funds")); } else { SendVoucher(consumerUserID, recipientID, transferAmount, 21, 2); MConsumerController consumerCtrl = new MConsumerController(consumerUserID); consumerCtrl = await consumerCtrl.init(); await consumerCtrl.sendVoucherToConsumer(recipientID, Decimal.ToInt32(transferAmount)); } } else { return(BadRequest("Recipient details invalid")); } return(Ok()); } else { return(BadRequest("Sender and Receiver must both be of type Consumer")); } }