summaryrefslogtreecommitdiff
path: root/Pages/Feed.xml.cshtml
diff options
context:
space:
mode:
Diffstat (limited to 'Pages/Feed.xml.cshtml')
-rw-r--r--Pages/Feed.xml.cshtml42
1 files changed, 42 insertions, 0 deletions
diff --git a/Pages/Feed.xml.cshtml b/Pages/Feed.xml.cshtml
new file mode 100644
index 0000000..c17981f
--- /dev/null
+++ b/Pages/Feed.xml.cshtml
@@ -0,0 +1,42 @@
+@page "/feed.yml"
+@using Microsoft.AspNetCore.Http
+@using Microsoft.EntityFrameworkCore
+@inject MyDarling.Models.DataContext context
+@{
+ var p =
+ new { Url = "https://mydarlingunderwear.ru/", LastUpdated = DateTime.Today };
+ Response.ContentType = "text/xml";
+ var products = context.Products
+ .Include(b => b.Figures)
+ .Where(b => b.Price != 0 && b.Figures.Count > 0);
+ await Response.WriteAsync("<?xml version='1.0' encoding='UTF-8' ?>");
+ var updateDate = p.LastUpdated.ToString("yyyy-MM-dd");
+}
+
+<yml_catalog date="@updateDate">
+ <shop>
+ <name>My Darling Underwear</name>
+ <company>Екатерина Мануйлова</company>
+ <url>@p.Url</url>
+ <currencies>
+ <currency id="RUB" rate="1"></currency>
+ </currencies>
+ <categories>
+ <category id="1">Нижнее бельё</category>
+ </categories>
+ <offers>
+ @foreach (var product in products)
+ {
+ var figureUrl = $"{@p.Url}Content/{@product.Id}/{@product.Figures[0].Id}.jpg";
+ <offer id="@product.Id" available="true">
+ <url>@p.Url#@product.Id-1</url>
+ <price>@product.Price</price>
+ <currencyId>RUR</currencyId>
+ <categoryId>1</categoryId>
+ <name>@product.Name</name>
+ <picture>@figureUrl</picture>
+ </offer>
+ }
+ </offers>
+ </shop>
+</yml_catalog> \ No newline at end of file