public Task <IEnumerable <LayoutDto> > GetLayoutsByVenue(int venueId) { var data = (from layouts in _context.LayoutRepository.GetList() where layouts.VenueId == venueId select layouts).ToList(); return(Task.FromResult(data.Select(x => LayoutParser.MapToLayoutDto(x)))); }
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 <IEnumerable <LayoutDto> > GetList() { var list = await _context.LayoutRepository.GetListAsync(); return(list.Select(x => LayoutParser.MapToLayoutDto(x))); }
public async Task <LayoutDto> Get(int id) { var layout = await _context.LayoutRepository.GetAsync(id); return(layout == null? null: LayoutParser.MapToLayoutDto(layout)); }