public void SubmitOrderRequest(OrderRequest request) { using (var db = new OrderDataContext()) { var order = new OrderEntity { ConfirmationEmailAddress = request.ConfirmationEmailAddress, DateCreated = DateTime.Now, RequestedDeliveryDate = request.RequestedDeliveryDate, VendorNumber = request.VendorNumber, OrderItems = new Collection<OrderItemEntity>() }; foreach(var item in request.LineItems) { var orderItem = new OrderItemEntity { ProductIdentifier = item.ProductIdentifier, Quantity = item.Quanity }; order.OrderItems.Add(orderItem); } db.Orders.Add(order); db.SaveChanges(); } }
static void Main() { Enumerable.Range(0, 10000).AsParallel().ForAll( (i) => { var channel = new ChannelFactory<ISubmitOrderService>( new MsmqDemoBinding(), "net.msmq://localhost/private/MsmqDemo/SubmitOrderService.svc" ); var client = channel.CreateChannel(); var orderRequest = new OrderRequest { ConfirmationEmailAddress = @"*****@*****.**", RequestedDeliveryDate = DateTime.Now, VendorNumber = "1" }; orderRequest.LineItems.Add(new OrderLineItem { ProductIdentifier = @"Blah", Quanity = 42 }); client.SubmitOrderRequest(orderRequest); } ); }
private static void SumbitOrder(Order order) { var request = new OrderRequest { ConfirmationEmailAddress = order.EmailAddress, RequestedDeliveryDate = order.RequestedDeliveryDate.Date, VendorNumber = order.VenderNumber }; if (order.QuantityBottledRainbows > 0) { var item = new OrderLineItem { ProductIdentifier = "BottledRainbows", Quanity = order.QuantityBottledRainbows }; request.LineItems.Add(item); } if (order.QuantityEsessenceOfBacon > 0) { var item = new OrderLineItem { ProductIdentifier = "EsessenceOfBacon", Quanity = order.QuantityEsessenceOfBacon }; request.LineItems.Add(item); } if (order.QuantityPowderedUnicornHorns > 0) { var item = new OrderLineItem { ProductIdentifier = "PowderedUnicornHorns", Quanity = order.QuantityPowderedUnicornHorns }; request.LineItems.Add(item); } var channel = new ChannelFactory<ISubmitOrderService>( new MsmqDemoBinding(), @"net.msmq://localhost/private/DemoQueue"); var client = channel.CreateChannel(); client.SubmitOrderRequest(request); }