public IActionResult CowCreate([FromBody] CowCreate dto) { try { //Her brewak point-> husk _storage.Store(dto.EarTag, dto.Name, dto.Birthday); return(Ok()); } catch { return(BadRequest()); } }
public IActionResult CowCreate([FromBody] CowCreate dto) { try { // _storage.Store(dto.EarTag, dto.Name, dto.Birthday); var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { //channel.QueueDeclare(queue: "cow_queue", // durable: false, // exclusive: false, // autoDelete: false, // arguments: null); string message = JsonConvert.SerializeObject(dto); var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchange: "", routingKey: "cow_queue", basicProperties: null, body: body); Console.WriteLine(" [x] Sent {0}", message); } return(Ok()); } catch { return(BadRequest()); } }