public Task <VenueDto> GetFullModel(int id) { var data = (from venues in _context.VenueRepository.GetList() join layotus in _context.LayoutRepository.GetList() on venues.Id equals layotus.VenueId join areas in _context.AreaRepository.GetList() on layotus.Id equals areas.LayoutId join seats in _context.SeatRepository.GetList() on areas.Id equals seats.AreaId where venues.Id == id select new { Venue = venues, Layout = layotus, Area = areas, Seat = seats }).ToList(); if (!data.Any()) { return(null); } var venue = data.FirstOrDefault().Venue; var result = VenueParser.MapToVenueDto(venue); foreach (var row in data) { var layout = result.LayoutList.SingleOrDefault(x => x.Id == row.Layout.Id); //add layout if it isn't exist in a result if (layout is null) { layout = LayoutParser.MapToLayoutDto(row.Layout); result.LayoutList.Add(layout); } var area = layout.AreaList.SingleOrDefault(x => x.Id == row.Area.Id); //add area if it isn't exist in a result if (area is null) { area = AreaParser.MapToAreaDto(row.Area); layout.AreaList.Add(area); } area.SeatList.Add(SeatParser.MapToSeatDto(row.Seat)); } return(Task.FromResult(result)); }
public async Task <VenueDto> Get(int id) { var venue = await _context.VenueRepository.GetAsync(id); return(venue == null ? null : VenueParser.MapToVenueDto(venue)); }
public async Task <IEnumerable <VenueDto> > GetList() { var list = await _context.VenueRepository.GetListAsync(); return(list.Select(x => VenueParser.MapToVenueDto(x))); }