public async Task <JsonResult> OnGetParticipants(int?id)
        {
            if (id == null)
            {
                return(new JsonResult("No event id submitted."));
            }

            var registrations = await _context.Registrations
                                .Where(
                r => r.EventInfoId == id &&
                r.Status != RegistrationStatus.Cancelled &&
                r.Type == RegistrationType.Participant)
                                .Include(r => r.Orders)
                                .ThenInclude(o => o.OrderLines)
                                .ThenInclude(ol => ol.Product)
                                .Include(r => r.Orders)
                                .ThenInclude(o => o.OrderLines)
                                .ThenInclude(ol => ol.ProductVariant)
                                .Include(r => r.User)
                                .ToListAsync();

            var vms = registrations.Select(x => new RegistrationsVm
            {
                RegistrationId = x.RegistrationId,
                Name           = x.User.Name,
                Email          = x.User.Email,
                Phone          = x.User.PhoneNumber,
                userId         = x.User.Id,
                JobTitle       = x.ParticipantJobTitle,
                Notes          = x.Notes,
                Employer       = x.ParticipantEmployer,
                City           = x.ParticipantCity,
                Products       = x.Products.Select(dto => ValueTuple.Create(
                                                       new RegistrationsProductVm(dto.Product),
                                                       RegistrationsVariantVm.Create(dto.Variant),
                                                       dto.Quantity)).ToList(),
                HasCertificate = x.HasCertificate,
                CertificateId  = x.CertificateId,
                Status         = x.Status.ToString(),
                Type           = x.Type.ToString()
            });

            if (vms.Any())
            {
                return(new JsonResult(vms));
            }
            else
            {
                return(new JsonResult("none"));
            }
        }
예제 #2
0
 public RegistrationOrderVm(Product product, ProductVariant variant, int quantity)
 {
     this.Item1 = new RegistrationsProductVm(product);
     this.Item2 = RegistrationsVariantVm.Create(variant);
     this.Item3 = quantity;
 }