public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, ILogger log) { var buyerName = req.Query["BuyerName"].ToString(); var purchaseOrderNumber = req.Query["PurchaseOrderNumber"].ToString(); var billingZipCode = req.Query["BillingZipCode"].ToString(); var orderAmount = req.Query["OrderAmount"].ToString(); var ser = new VibOrderRepository(); var param = new VibOrder { BillingZipCode = billingZipCode, BuyerName = buyerName, PurchaseOrderNumber = purchaseOrderNumber }; if (orderAmount.IsNotNullOrEmpty()) { param.OrderAmount = orderAmount.ToDecimal(); } var orders = ser.GetOrders(param); return(await Task.FromResult(new OkObjectResult(orders))); }
public IEnumerable <VibOrder> GetOrders(VibOrder order) { var sql = "select * from viborder where 1=1 "; if (order.PurchaseOrderNumber.IsNotNullOrEmpty()) { sql += "and PurchaseOrderNumber = @PurchaseOrderNumber "; } if (order.BillingZipCode.IsNotNullOrEmpty()) { sql += "and BillingZipCode = @BillingZipCode "; } if (order.BuyerName.IsNotNullOrEmpty()) { sql += "and BuyerName = @BuyerName "; } if (order.OrderAmount != 0) { sql += "and OrderAmount = @OrderAmount "; } return(_db.Query <VibOrder>(sql, order)); }
public void CreateOrder(VibOrder order) { var sql = @"insert into VibOrder values( @PurchaseOrderNumber, @BillingZipCode, @BuyerName, @OrderAmount );"; _db.Execute(sql, order); }