public ActionResult Index(int productId) { //Read from the product service Product productById = _productService.GetProductById(productId); //If the product exists we will log it if (productById != null) { //Setup the product to save var record = new TrackingRecord(); record.ProductId = productId; record.ProductName = productById.Name; record.CustomerId = _workContext.CurrentCustomer.Id; record.IpAddress = _workContext.CurrentCustomer.LastIpAddress; record.IsRegistered = _workContext.CurrentCustomer.IsRegistered(); //Map the values we're interested in to our new entity _viewTrackingService.Log(record); } //Return the view, it doesn't need a model return Content(""); }
/// <summary> /// Logs the specified record. /// </summary> /// <param name="record">The record.</param> public void Log(TrackingRecord record) { _trackingRecordRepository.Insert(record); }