public async Task <bool> PopulateEventsAsync(Artist artist)
        {
            try
            {
                var baseUrl = string.Format(BandsInTownApiBaseUrl, _webHelperService.UrlEncode(artist.Name));

                var jsonString = await _webHelperService.HttpGetAsync(baseUrl, GetUrlParameters());

                HandleErrors(jsonString);

                artist.UpcomingEvents = GetEventsList(jsonString, artist.Name).OrderBy(ev => ev.Date).ToList();

                return(true);
            }
            catch (ServiceException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ServiceException("Unexpected error while fetching artist event", ex);
            }
        }
示例#2
0
        public IElementContent GetContent(IElementSettings settings, IPageContext pageContext, IUnitOfWork unitOfWork = null)
        {
            // Construct element content
            ShareContent shareContent = new ShareContent();

            // Get this page's URL
            // UrlParameters urlParameters = new UrlParameters { RouteName = "ReadPage", RouteValues = new { pageid = pageContext.Page.PageId, description = pageContext.Page.Description } };
            string url = _webHelperService.GetRequestUrl(); // _webHelperService.GetUrl(urlParameters);

            // Populate element content
            shareContent.PartialViewName = "Share";
            shareContent.Description     = _webHelperService.UrlEncode(pageContext.Page.Description ?? string.Empty);
            shareContent.Hashtags        = _webHelperService.UrlEncode(string.Empty);
            shareContent.Image           = _webHelperService.UrlEncode(string.Empty);
            shareContent.IsVideo         = _webHelperService.UrlEncode(string.Empty);
            shareContent.Title           = _webHelperService.UrlEncode(pageContext.Page.Name);
            shareContent.Url             = _webHelperService.UrlEncode(url);

            // Return resulting element content
            return(shareContent);
        }