public async Task <GoogleDirectionsObject[]> GetWaypointsFromWishlist() { if (await CurrentExtensions.RestrictAdministratorResource(contextFactory, httpContext)) { throw new ArgumentException("Administrators cannot intact with their wishlist!"); } using (var a = contextFactory.CreateDbContext()) { var wishlist = await a.WishList.Include(x => x.User).Include(x => x.Locations).Where(x => x.User.Auth == httpContext.GetCurrentAuth()).FirstOrDefaultAsync(); if (wishlist == null) { throw new ArgumentException("Something went wrong. User doesn't have a wishlist"); } var waypoints = await googleService.DirectionsServiceTest("Moscow", "Sofia", wishlist.Locations.Select(x => x.PlaceId).ToArray()); return(waypoints); } }