public async Task <ActionResult <VenteItem> > PostVenteItem(VenteItem venteItem) { reponse = ""; Task <IConnection> connection = ConnexionSingleton.Connexion("localhost", "guest", "guest", new ConnectionFactory()); RabbitMQContext rabbitMQContext = new RabbitMQContext(connection.Result.CreateModel()); string message = JsonConvert.SerializeObject(venteItem); rabbitMQContext.OnRecupererReponse += TraiterReponse; rabbitMQContext.PublierMessage(message); while (reponse == "") { } if (reponse == "Valide") { _context.ProduitItems.Add(venteItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetVenteItem", new { id = venteItem.Id }, venteItem)); } else { return(null); } }
public Startup(IConfiguration configuration) { Configuration = configuration; Task <IConnection> connection = ConnexionSingleton.Connexion("localhost", "guest", "guest", new ConnectionFactory()); rabbitMQContext = new RabbitMQContext(connection.Result.CreateModel()); rabbitMQContext.OnConsommerMessage += TraiterReq; rabbitMQContext.ConsommerMessage(); }