Пример #1
0
        public async Task <IActionResult> ListAccessibleOrders([FromQuery] OrdersQueryDto query)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.FormatErrors()));
            }

            var paging = await _orderRetrievalService.ListOrdersAsync(new OrderListRequest
            {
                Limit  = query.Limit,
                Offset = query.Offset,
                Filter = new OrderListFilter
                {
                    EventId        = query.EventId,
                    UserId         = query.UserId,
                    RegistrationId = query.RegistrationId,
                    Status         = query.Status,
                    AccessibleOnly = true
                }
            }, new OrderRetrievalOptions
            {
                IncludeUser         = query.IncludeUser,
                IncludeRegistration = query.IncludeRegistration,
                IncludeOrderLines   = true
            });

            return(Ok(PageResponseDto <RegistrationOrderDto> .FromPaging(
                          query, paging, o => new OrderDto(o))));
        }
        public async Task <IActionResult> List(int id,
                                               [FromQuery] EventCertificateQueryDto query,
                                               CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.FormatErrors()));
            }

            var eventInfo = await _eventInfoRetrievalService.GetEventInfoByIdAsync(id, cancellationToken);

            await _eventInfoAccessControlService.CheckEventManageAccessAsync(eventInfo, cancellationToken);

            var certificates = await _certificateRetrievalService
                               .ListCertificatesAsync(new CertificateListRequest
            {
                Limit  = query.Limit,
                Offset = query.Offset,
                Filter = new CertificateFilter
                {
                    EventId = id
                }
            }, new CertificateRetrievalOptions
            {
                LoadIssuingOrganization = true,
                LoadIssuingUser         = true,
                LoadRecipientUser       = true
            }, cancellationToken);

            return(Ok(PageResponseDto <EventDto> .FromPaging(
                          query, certificates,
                          c => new CertificateDto(c))));
        }
Пример #3
0
        public async Task <PageResponseDto <EventDto> > List(
            [FromQuery] EventsQueryDto query,
            CancellationToken cancellationToken)
        {
            var events = await _eventInfoService
                         .ListEventsAsync(new EventListRequest(query.Offset, query.Limit)
            {
                Filter = query.ToEventInfoFilter()
            }, cancellationToken : cancellationToken);

            return(PageResponseDto <EventDto> .FromPaging(
                       query, events, e => new EventDto(e)));
        }
Пример #4
0
        public async Task <PageResponseDto <UserDto> > List(
            [FromQuery] UsersQueryDto request,
            CancellationToken cancellationToken)
        {
            var paging = await _userRetrievalService
                         .ListUsers(
                new UserListRequest
            {
                Filter     = request.ToUserFilter(),
                Limit      = request.Limit,
                Offset     = request.Offset,
                OrderBy    = request.Order,
                Descending = request.Descending
            },
                UserRetrievalOptions.Default,
                cancellationToken);

            return(PageResponseDto <UserDto> .FromPaging(
                       request, paging, u => new UserDto(u)));
        }
Пример #5
0
        public async Task <IActionResult> List(
            [FromQuery] NotificationsQueryDto query,
            CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.FormatErrors()));
            }

            var paging = await _notificationRetrievalService
                         .ListNotificationsAsync(
                new NotificationListRequest
            {
                Limit  = query.Limit,
                Offset = query.Offset,
                Filter = new NotificationFilter
                {
                    AccessibleOnly  = true,
                    EventId         = query.EventId,
                    ProductId       = query.ProductId,
                    RecipientUserId = query.RecipientUserId,
                    Statuses        = query.Status.HasValue
                                ? new[] { query.Status.Value }
                                : null,
                    Types = query.Type.HasValue
                                ? new[] { query.Type.Value }
                                : null
                },
                OrderBy    = query.Order,
                Descending = query.Desc
            },
                new NotificationRetrievalOptions
            {
                LoadStatistics = query.IncludeStatistics
            },
                cancellationToken);

            return(Ok(PageResponseDto <NotificationDto> .FromPaging(
                          query, paging, n => new NotificationDto(n))));
        }
        public async Task <IActionResult> List(int id,
                                               [FromQuery] NotificationRecipientsQueryDto request,
                                               CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.FormatErrors()));
            }

            await _notificationRetrievalService.GetNotificationByIdAsync(id,
                                                                         cancellationToken : cancellationToken); // for ensuring notification exists

            var paging = await _notificationRecipientRetrievalService
                         .ListNotificationRecipientsAsync(
                new NotificationRecipientListRequest
            {
                Limit  = request.Limit,
                Offset = request.Offset,
                Filter = new NotificationRecipientFilter
                {
                    AccessibleOnly  = true,
                    NotificationIds = new[] { id },
                    Query           = request.Query,
                    SentOnly        = request.SentOnly,
                    ErrorsOnly      = request.ErrorsOnly
                },
                OrderBy    = request.Order,
                Descending = request.Desc
            },
                new NotificationRecipientRetrievalOptions
            {
                LoadRegistration = true,
                LoadUser         = true
            },
                cancellationToken);

            return(Ok(PageResponseDto <NotificationRecipientDto> .FromPaging(
                          request, paging, r => new NotificationRecipientDto(r))));
        }
Пример #7
0
        public async Task <PageResponseDto <RegistrationDto> > GetRegistrations(
            [FromQuery] PageQueryDto query,
            CancellationToken cancellationToken)
        {
            var paging = await _registrationRetrievalService
                         .ListRegistrationsAsync(
                new RegistrationListRequest
            {
                Limit  = query.Limit,
                Offset = query.Offset,
                Filter = new RegistrationFilter
                {
                    AccessibleOnly = true
                },
                OrderBy    = RegistrationListOrder.RegistrationTime,
                Descending = true
            },
                RegistrationRetrievalOptions.Default,
                cancellationToken);

            return(PageResponseDto <RegistrationDto> .FromPaging(
                       query, paging, r => new RegistrationDto(r)));
        }