Beispiel #1
0
        public async Task <IActionResult> AuditAsync(UnverifyAuditFilterFormData formData = null)
        {
            if (formData == null)
            {
                formData = new UnverifyAuditFilterFormData();
            }

            if (formData.GuildID == 0)
            {
                formData.GuildID = DiscordClient.Guilds.FirstOrDefault()?.Id ?? 0;
            }

            if (formData.Page < 1)
            {
                formData.Page = 1;
            }

            var errorMessage = Request.Query.TryGetValue("ErrMsg", out var values) ? values.ToString() : null;
            var logs         = await UnverifyService.UnverifyLogger.GetLogsAsync(formData);

            var pagination = await UnverifyService.UnverifyLogger.CreatePaginationInfo(formData);

            var viewModel = new UnverifyAuditViewModel(DiscordClient, logs, formData, pagination, errorMessage);

            return(View(viewModel));
        }
Beispiel #2
0
        public async Task <List <UnverifyLogItem> > GetLogsAsync(UnverifyAuditFilterFormData formData)
        {
            var filter = await Converter.ConvertAuditFilter(formData);

            var data = await GrillBotRepository.UnverifyRepository.GetLogs(filter).ToListAsync();

            return(data.ConvertAll(o => new UnverifyLogItem(o, Discord)));
        }
Beispiel #3
0
        public async Task <PaginationInfo> CreatePaginationInfo(UnverifyAuditFilterFormData formData)
        {
            var filter = await Converter.ConvertAuditFilter(formData);

            var logsCount = await GrillBotRepository.UnverifyRepository.GetLogs(filter, true).CountAsync();

            return(new PaginationInfo(filter.Skip, formData.Page, logsCount));
        }
Beispiel #4
0
        public async Task <PaginationInfo> CreatePaginationInfo(UnverifyAuditFilterFormData formData)
        {
            var filter = await Converter.ConvertAuditFilter(formData);

            var logsCount = await GrillBotRepository.UnverifyRepository.GetLogs(filter, true).CountAsync();

            return(new PaginationInfo()
            {
                CanPrev = filter.Skip != 0,
                CanNext = filter.Skip + filter.Take < logsCount,
                Page = formData.Page,
            });
        }
        public async Task <UnverifyAuditFilter> ConvertAuditFilter(UnverifyAuditFilterFormData formData)
        {
            if (formData.Page < 0)
            {
                formData.Page = 0;
            }

            var result = new UnverifyAuditFilter()
            {
                DateTimeFrom = formData.DateTimeFrom,
                DateTimeTo   = formData.DateTimeTo,
                Guild        = DiscordClient.GetGuild(formData.GuildID),
                Operation    = formData.Operation,
                OrderAsc     = formData.OrderAsc,
                Skip         = (formData.Page == 0 ? 0 : formData.Page - 1) * PageSize,
                Take         = PageSize
            };

            result.FromUsers = await UserSearch.FindUsersAsync(result.Guild, formData.FromUserQuery);

            result.ToUsers = await UserSearch.FindUsersAsync(result.Guild, formData.ToUserQuery);

            return(result);
        }