private async Task <StaticPagedList <PublicationViewModel> > GetPublications() { var pagedResult = await _publicationService.GetPublications(); var categories = await _publicationService.GetCategories(); var publications = pagedResult.Select(o => new PublicationViewModel(o, _settings.WebSiteUrl, categories)); return(new StaticPagedList <PublicationViewModel>(publications, pagedResult)); }
public async Task <IActionResult> GetSitemap() { var page = 1; var key = "sitemap"; var xml = _cache.Get(key)?.ToString(); if (string.IsNullOrEmpty(xml)) { IPagedList <Publication> publications; IPagedList <Vacancy> vacancies; var sitemap = new Sitemap(); var events = GetCustomPages(); foreach (var url in events) { sitemap.Add(CreateUrl(url)); } page = 1; do { publications = await _publicationService.GetPublications(null, page); page++; foreach (var p in publications) { var publication = new PublicationViewModel(p, _settings.WebSiteUrl); sitemap.Add(CreateUrl(publication.ShareUrl.ToString())); } }while (publications.HasNextPage); page = 1; do { vacancies = await _vacancyService.GetVacancies(page); page++; foreach (var v in vacancies) { var vacancy = new VacancyViewModel(v, _settings.WebSiteUrl); sitemap.Add(CreateUrl(vacancy.ShareUrl.ToString())); } }while (vacancies.HasNextPage); xml = sitemap.ToXml(); _cache.Set(key, xml, TimeSpan.FromMinutes(10)); } return(Content(xml, "application/xml")); }
public async Task <IActionResult> GetPosts() { var publications = await _publicationService.GetPublications(); var publicationsDTO = _mapper.Map <IEnumerable <PublicationDTO> >(publications); var response = new ApiResponse <IEnumerable <PublicationDTO> >(publicationsDTO); return(Ok(response)); }
public async Task <IActionResult> GetRssFeed() { var key = "rss"; var xml = _cache.Get(key)?.ToString(); if (string.IsNullOrEmpty(xml)) { int?categoryId = null; var pagedResult = await _publicationService.GetPublications(categoryId, 1, 50); var lastUpdateDate = pagedResult.Select(o => o.DateTime).DefaultIfEmpty().Max(); var rss = new RssDocument { Channel = new RssChannel { Copyright = _settings.WebSiteTitle, Description = _settings.DefaultDescription, SkipDays = new List <Day>(), SkipHours = new List <Hour>(), AtomLink = new RssLink(_settings.RssFeedUrl), Image = new RssImage { Description = _settings.WebSiteTitle, Height = 100, Width = 100, Link = new RssUrl(_settings.FacebookImage), Title = _settings.WebSiteTitle, Url = new RssUrl(_settings.FacebookImage) }, Language = new CultureInfo("ru"), LastBuildDate = lastUpdateDate, Link = new RssUrl(_settings.RssFeedUrl), ManagingEditor = new RssPerson("Andrew G.", _settings.SupportEmail), PubDate = lastUpdateDate, Title = _settings.WebSiteTitle, TTL = 10, WebMaster = new RssPerson("Andrew G.", _settings.SupportEmail), Items = new List <RssItem> { } } }; foreach (var p in pagedResult) { rss.Channel.Items.Add(CreateRssItem(p)); } xml = rss.ToXml(); _cache.Set(key, xml, TimeSpan.FromMinutes(10)); } return(Content(xml, RssDocument.MimeType)); }
public async Task <StaticPagedList <PublicationViewModel> > GetPublications(int?categoryId = null, int page = 1) { var categories = await GetCategories(); var pagedResult = await _publicationService.GetPublications(categoryId, page); var publications = pagedResult .Select(o => new PublicationViewModel(o, _settings.WebSiteUrl, categories)) .ToImmutableList(); return(new StaticPagedList <PublicationViewModel>(publications, pagedResult)); }
[AllowAnonymous] // DEBUG public async Task <IHttpActionResult> GetPublications() => Ok(await _publicationService.GetPublications());