private static Message ToMessage(RestaurantOrderViewModel model) { var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model)); var message = new Message { Body = body, ContentType = "text/plain", }; return(message); }
public async Task Send(RestaurantOrderViewModel viewModel) { var message = ToMessage(viewModel); try { await _topicClient.SendAsync(message); } catch (Exception ex) { Debug.WriteLine($"Exception: {ex.Message}"); } finally { await _topicClient.CloseAsync(); } }
public async Task <IActionResult> Index(RestaurantOrderViewModel viewModel) { await _publisherService.Send(viewModel); return(RedirectToAction("Success", "Home")); }