Пример #1
0
        /// <summary>
        ///     Method used to execute the query
        /// </summary>
        /// <param name="query">Query to execute.</param>
        /// <returns>
        ///     Task which will contain the result once completed.
        /// </returns>
        public async Task <GetApplicationInfoResult> HandleAsync(IMessageContext context, GetApplicationInfo query)
        {
            Application app;

            if (!string.IsNullOrEmpty(query.AppKey))
            {
                app = await _repository.GetByKeyAsync(query.AppKey);
            }
            else
            {
                app = await _repository.GetByIdAsync(query.ApplicationId);
            }

            var totalCount = await _incidentRepository.GetTotalCountForAppInfoAsync(app.Id);

            var versions = await _versionRepository.FindVersionsAsync(app.Id);

            return(new GetApplicationInfoResult
            {
                AppKey = app.AppKey,
                ApplicationType = app.ApplicationType.ConvertEnum <TypeOfApplication>(),
                Id = app.Id,
                Name = app.Name,
                SharedSecret = app.SharedSecret,
                TotalIncidentCount = totalCount,
                Versions = versions.ToArray()
            });
        }