public async Task <IViewComponentResult> InvokeAsync() { try { IEnumerable <Tour> popularTours = await tourDAL.GetTrendingToursAsync(); if (popularTours != null) { foreach (Tour tour in popularTours) { tour.Destinations = await tourDAL.FindDestinationsByTourIdAsync(tour.Id); } } AppUser user = User?.Identity?.Name == null ? null : await userManager.FindByNameAsync(User.Identity.Name); string avatar = "https://ztourist.blob.core.windows.net/others/avatar.png"; if (user != null) { avatar = user.Avatar; } if (cart != null && cart.Lines.Count() > 0) { foreach (CartLine cartLine in cart.Lines) { cartLine.Tour = await tourDAL.FindTourByTourIdAsync(cartLine.Tour.Id); } } NavigationViewModel model = new NavigationViewModel { Cart = cart, PopularTours = popularTours, Avatar = avatar }; return(View(model)); } catch (Exception ex) { logger.Error(ex.Message); throw; } }