public void SendClick(ClickEvent click) { var serializedString = JsonConvert.SerializeObject(click); EventData data = new EventData(Encoding.UTF8.GetBytes(serializedString)) { PartitionKey = click.productId.ToString() }; // Set user properties if needed data.Properties.Add("Type", "Telemetry_" + DateTime.UtcNow.ToLongTimeString()); _eventHubs._clickClient.Send(data); //TODO: Add output to log here. }
public ActionResult Details(Int64 id) { var product = _productsRepository.GetProduct(id); if (product == null) { return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound); } var relatedCatalogItems = new List<CatalogItem>(); IEnumerable<Product> relatedProducts = new List<Product>(); IEnumerable<Promotion> promotions = null; Customer customer = null; relatedProducts = _productsRepository.GetRelatedProducts(product.Id); var clickEvent = new ClickEvent { clickTime = DateTime.Now, productId = product.Id }; _telemetryRepository.SendClick(clickEvent); if (User.Identity.IsAuthenticated) { customer = _customerRepository.GetCustomerByName(User.Identity.Name); promotions = _promotionsRepository.GetPromotions(customer.Id); } foreach (var relatedProduct in relatedProducts.OrderBy(p => p.Name)) { relatedCatalogItems.Add(ProductToCatalogItem(promotions, customer, relatedProduct)); } return View(new CatalogItemDetailsModel(ProductToCatalogItem(promotions, customer, product), relatedCatalogItems)); }