/// <summary>
        ///     Execute a command asynchronously.
        /// </summary>
        /// <param name="command">Command to execute.</param>
        /// <returns>
        ///     Task which will be completed once the command has been executed.
        /// </returns>
        public async Task HandleAsync(IMessageContext context, UpdateNotifications command)
        {
            var settings = await _notificationsRepository.TryGetAsync(command.UserId, command.ApplicationId);

            if (settings == null)
            {
                settings = new UserNotificationSettings(command.UserId, command.ApplicationId);
                await _notificationsRepository.CreateAsync(settings);
            }

            settings.ApplicationSpike = command.NotifyOnPeaks.ConvertEnum <NotificationState>();
            settings.NewIncident      = command.NotifyOnNewIncidents.ConvertEnum <NotificationState>();
            settings.ReopenedIncident = command.NotifyOnReOpenedIncident.ConvertEnum <NotificationState>();
            settings.UserFeedback     = command.NotifyOnUserFeedback.ConvertEnum <NotificationState>();
            await _notificationsRepository.UpdateAsync(settings);
        }
        public async Task <GetUserSettingsResult> ExecuteAsync(GetUserSettings query)
        {
            var settings = await _repository.TryGetAsync(query.UserId, query.ApplicationId)
                           ?? new UserNotificationSettings(query.UserId, query.ApplicationId);

            var user = await _userRepository.GetUserAsync(query.UserId);

            return(new GetUserSettingsResult
            {
                FirstName = user.FirstName,
                LastName = user.LastName,
                MobileNumber = user.MobileNumber,
                Notifications = new NotificationSettings
                {
                    NotifyOnReOpenedIncident = settings.ReopenedIncident.ConvertEnum <NotificationState>(),
                    NotifyOnUserFeedback = settings.UserFeedback.ConvertEnum <NotificationState>(),
                    NotifyOnPeaks = settings.ApplicationSpike.ConvertEnum <NotificationState>(),
                    NotifyOnNewReport = settings.NewReport.ConvertEnum <NotificationState>(),
                    NotifyOnNewIncidents = settings.NewIncident.ConvertEnum <NotificationState>()
                }
            });
        }