Пример #1
0
        public async Task <IActionResult> GetRoutes(MetricsQuery query)
        {
            var user = await _userRepository.GetUser(User.ParseAllClaims().User.Id);

            if (_sysAdminService.IsUserSysAdmin(user))
            {
                var routes = await _apiLogRepository.SearchApiLogs(query.From, query.To, query.UserId, query.Route);

                var grouped = routes.GroupBy(x => x.Route)
                              .Select(x => new { Route = x.Key, Count = x.Count() })
                              .OrderBy(x => x.Count)
                              .ToList();

                return(Ok(grouped));
            }
            else
            {
                return(Forbid());
            }
        }