private T[] SideLoad <T>(List <T> resources, Func <T, bool> p, SideLoads include) { var name = $"{typeof(T).Name}s".ToLower(); if (!include.ToString().Contains(name)) { return new T[] { } } ; return(resources.Where(p).ToArray()); }
public Task <TicketResponse> GetTicketWithSideloads(long id, SideLoads include) { var ticket = Tickets.First(x => x.Id == id); var response = new TicketResponse { Ticket = ticket }; response.Users = SideLoad(Users, x => x.Id == response.Ticket.RequesterId, include); response.Organizations = SideLoad(Organizations, x => x.Id == response.Ticket.OrganizationId, include); return(Task.FromResult(response)); }
public Task <TicketResponse> GetTicketWithSideloads([Path] long id, SideLoads include) => GetTicket(id);