public async Task <CoordinateList> GetCoordinateList(int coordinateListId) { CoordinateListDto coordinateListDto = await CoordinateLists .AsQueryable() .FirstOrDefaultAsync(x => x.Id == coordinateListId) .ConfigureAwait(false); List <CoordinateDto> coordinateDtos = await Coordinates .AsQueryable() .Where(x => x.CoordinateListId == coordinateListId) .ToListAsync() .ConfigureAwait(false); CoordinateList coordinateList = DtoMapper.Map(coordinateListDto, coordinateDtos); return(coordinateList); }
public async Task <CoordinateList> CreateCoordinateList(List <Coordinate> coordinates) { CoordinateListDto coordinateListDto = new CoordinateListDto(); CoordinateLists.Add(coordinateListDto); await SaveChangesAsync().ConfigureAwait(false); coordinates.ForEach(x => x.CoordinateListId = coordinateListDto.Id); List <CoordinateDto> coordinateDtos = coordinates.Select(DtoMapper.Map).ToList(); Coordinates.AddRange(coordinateDtos); await SaveChangesAsync().ConfigureAwait(false); CoordinateList createdCoordinateList = DtoMapper.Map(coordinateListDto, coordinateDtos); return(createdCoordinateList); }