Esempio n. 1
0
        public async Task <ActionResult <Order> > CreateOrder()
        {
            Order order = null;

            try
            {
                order = await _orderService.CreateOrderAsync();
            }
            catch (Exception ex)
            {
                await _telemetrySubmitter.SubmitAsync(new ServiceOperation
                {
                    ErrorMessage = ex.Message,
                    ServiceName  = "OrdersController",
                    Operation    = "CreateOrder",
                    IsError      = 1,
                    StackTrace   = ex.StackTrace,
                });

                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Created($"{order.Id}", order));
        }
 /// <summary>
 /// Stops the timer and passes message to telemetry submitter.
 /// </summary>
 public void Dispose()
 {
     _message.Duration = _stopwatch.ElapsedMilliseconds;
     _telemetrySubmitter.SubmitAsync(_message);
 }