コード例 #1
0
        private ContentResult ListOfItemsXml()
        {
            _logger.LogInformation("responde with ListOfItemsXml");
            var stations = _stationsRepo.GetAllAsync().Result.Take(8);
            var doc      = new XDocument(
                new XDeclaration("1.0", "UTF-8", "yes"),
                new XElement("ListOfItems",
                             new XElement("ItemCount", stations.Count()),
                             stations.Select(x => new XElement("Item",
                                                               new XElement("ItemType", x.Item.ItemType),
                                                               new XElement("StationName", x.Item.StationName),
                                                               new XElement("StationUrl", x.Item.StationUrl)
                                                               )
                                             ))
                );
            var wr = new Utf8StringWriter();

            doc.Save(wr, SaveOptions.None);
            var xml = wr.ToString();

            //Response.ContentLength = xml.Length;
            Response.ContentType = "text/html";
            return(Content(xml));
        }
コード例 #2
0
 public async void OnGetAsync(string id)
 {
     Item = (await stationsRepo.GetAllAsync()).Single(x => x.Key == id).Item;
 }
コード例 #3
0
 public async Task OnGetAsync()
 {
     Stations = await _stationsRepo.GetAllAsync();
 }