コード例 #1
0
        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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        public async Task <IActionResult> Index(RestaurantOrderViewModel viewModel)
        {
            await _publisherService.Send(viewModel);

            return(RedirectToAction("Success", "Home"));
        }