Пример #1
0
        /// <summary>
        /// Asynchronous method that retrieves a Notification class based on the Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Filled Notification class or null</returns>
        public async Task <Notification> GetNotificationById(Guid id)
        {
            try
            {
                _logger.Information($"A request has been made to retrieve a Notification with id {id} from the context.");
                Notification n = await _notificationsRepo.GetNotificationById(id);

                return(n ?? throw new ArgumentNullException("Dependency failure: The repository returned null."));
            }
            catch (Exception e) // Error handling
            {
                _logger.Error($"INotificationsService says: {e.Message} Exception occured on line " +
                              $"{new StackTrace(e, true).GetFrame(0).GetFileLineNumber()}.");
                return(null);
            }
        }