public static async Task <IActionResult> InsertOrder([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "orders/new")] HttpRequest req, ILogger log) { log.LogInformation("Creating Order"); var neworder = new JsonSerializer().Deserialize <Order>(new JsonTextReader(new StreamReader(req.Body))); Options opts = GetOptions(); Orders orders = new Orders(opts, neworder.UserId); try { var retval = await orders.InsertOrder(neworder, Guid.NewGuid(), (int)Status.Filled); if (retval.ReturnCode == 0) { return(new OkObjectResult(retval.Balance)); } else if (retval.ReturnCode == 1) { return(Utility.APIError("Uh-oh!", "Invalid number of shares specified")); } else if (retval.ReturnCode == 2) { return(Utility.APIError("Uh-oh!", "Not enough funds to place this order")); } else if (retval.ReturnCode == 3) { return(Utility.APIError("Uh-oh!", "You do no own enough shares of the this trend")); } else if (retval.ReturnCode == 4) { return(Utility.APIError("Uh-oh!", "You cannot buy/sell trends with a price of zero. Trend may no longer be trending.")); } else { return(Utility.APIError("Uh-oh!", "Something Bad Happened! We're on it..")); } } catch (Exception e) { return(Utility.APIError("Uh-oh!", "Something Bad Happened! We're on it..")); } }