public ActionResult Index(string productId, string socketId) { ActionResult result = null; bool bought = MvcApplication.ProductRepository.Buy(productId); var model = MvcApplication.ProductRepository.GetProductById(productId); if (bought) { ViewBag.Info = model.Title + " successfully bought"; var stockEvent = new StockUpdatedEvent(model, socketId); ObjectPusherRequest request = new ObjectPusherRequest("presence-" + stockEvent.ProductId, "stockUpdated", stockEvent); _provider.Trigger(request); } else { ViewBag.Error = "There was a problem buying " + model.Title; } if (socketId != null) { result = GetBoughtStatusCode(bought); } else { result = View("Index", model); } return(result); }
public Task Handle(StockUpdatedEvent @event, CancellationToken cancellationToken) { return(_hubContext.Clients.All.SendAsync("stockUpdated", @event, cancellationToken)); }