public async Task <HttpResponseMessage> Sitemap() { var xmlWriter = new SitemapXmlWriter(); var activities = await _activityOperations.SearchAsync(isChecked : true, page : -1); // для активностей формируем урлы List <SitemapUrl> urls = GetActivitiesUrls(activities); urls.Add(new SitemapUrl { Priority = SitemapPagePriority.HIGH, ChangeFreq = SitemapPageChangeFrec.DAILY, Modified = DateTimeOffset.Now, Url = _baseUrl + "/" }); urls.Add(new SitemapUrl { Priority = SitemapPagePriority.HIGH, ChangeFreq = SitemapPageChangeFrec.DAILY, Modified = DateTimeOffset.Now, Url = _baseUrl + "/about" }); urls.Add(new SitemapUrl { Priority = SitemapPagePriority.HIGH, ChangeFreq = SitemapPageChangeFrec.DAILY, Modified = DateTimeOffset.Now, Url = _baseUrl + "/sponsor" }); urls.Add(new SitemapUrl { Priority = SitemapPagePriority.HIGH, ChangeFreq = SitemapPageChangeFrec.DAILY, Modified = DateTimeOffset.Now, Url = _baseUrl + "/member" }); // Формируем XML в MemoryStream var stream = xmlWriter.CreateXml(urls); // Полученный поток преобразуем в файл и отдаём наружу var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(stream.ToArray()) }; result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "sitemap.xml" }; result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml"); stream.Close(); return(result); }
public async Task <IHttpActionResult> Search(String word = null, int?age = null, int?interestId = null, int?cityId = null, bool?sobriety = null, bool?free = null, int page = 1) { try { var activities = await _activityOperations.SearchAsync(word, age, interestId, cityId, sobriety, free, true, page); var result = await ViewModelsFromEntities(activities); return(Ok(result)); } catch (Exception ex) { ErrorLogger.Log("CANNOT SEARCH ACTIVITY", ex); throw; } }
public void SearchNoParameters_Ok_Test() { var result = _activityOperations.SearchAsync(null, null, null, null, null, null, false, 1).Result; Assert.IsTrue(result.Any()); }