Esempio n. 1
0
 public IQueryable <OrderExpanded> FetchOrderList()
 {
     return(_context.Orders
            .Include(o => o.Client)
            .ThenInclude(o => o.Profiles)
            .Include(o => o.Ordered)
            .ThenInclude(o => o.Book)
            .ThenInclude(o => o.BookAuthors)
            .Include(o => o.Address)
            .Select(c => new OrderExpanded
     {
         Id = c.Id,
         Client = ClientExpanded.Create(c.Client, c.Client.Profiles.FirstOrDefault()),
         Address = _mapper.Map <AddressDTO>(c.Address),
         CreatedAt = c.CreatedAt,
         Products = c.Ordered.Select(x => new BookDTO
         {
             Id = x.Book.Id,
             CategoryId = x.Book.CategoryId,
             Title = x.Book.Title,
             CoverUrl = x.Book.CoverUrl,
             Price = x.Book.Price,
             Description = x.Book.Description,
             Pages = x.Book.Pages,
             Authors = x.Book.BookAuthors.Select(ctx => ctx.AuthorId).ToList()
         }).ToList(),
         Status = c.Status
     }));
 }
 public IQueryable<CaseExpanded> FetchCaseCollection()
 {
     return _context
         .Cases
         .Where(c => c.ClientId == Client.Id)
         .Include(c => c.Support)
         .ThenInclude(c => c.Profiles)
         .Include(c => c.Order)
         .ThenInclude(c => c.Address)
         .Select(c => new CaseExpanded
         {
             Id = c.Id,
             Support = ClientExpanded.Create(c.Support, c.Support.Profiles.FirstOrDefault()),
             Order = _mapper.Map<OrderDTO>(c.Order),
             Client = null,
             CreatedAt = c.CreatedAt,
             UpdatedAt = c.UpdatedAt,
             Status = c.Status,
             Title = c.Title
         });
 }
Esempio n. 3
0
 public IQueryable <CaseExpanded> FetchCaseCollection()
 {
     return(_context
            .Cases
            .Include(c => c.Client)
            .ThenInclude(c => c.Profiles)
            .Include(c => c.CaseMessages)
            .ThenInclude(c => c.CaseAttachments)
            .Include(c => c.Support)
            .ThenInclude(c => c.Profiles)
            .Include(c => c.Order)
            .ThenInclude(c => c.Address)
            .Select(c => new CaseExpanded
     {
         Id = c.Id,
         Support = ClientExpanded.Create(c.Support, c.Support.Profiles.FirstOrDefault()),
         Order = _mapper.Map <OrderDTO>(c.Order),
         Messages = c.CaseMessages.Select(ctx => new CaseMessageData
         {
             Id = ctx.Id,
             Contents = ctx.Contents,
             ClientId = ctx.ClientId,
             CreatedAt = ctx.CreatedAt,
             Attachments = ctx.CaseAttachments.Select(ctt => new CaseAttachmentDTO
             {
                 AttachmentUrl = ctt.AttachmentUrl,
                 CaseMessageId = ctx.Id,
                 Id = ctt.Id
             }).ToList()
         }).ToList(),
         Client = ClientExpanded.Create(c.Client, c.Client.Profiles.FirstOrDefault()),
         CreatedAt = c.CreatedAt,
         UpdatedAt = c.UpdatedAt,
         Status = c.Status,
         Title = c.Title
     }));
 }