Пример #1
0
        public async Task <IActionResult> Create(User user)
        {
            var newUser = _users.New();

            newUser.Data.Name     = user.Name;
            newUser.Data.LastName = user.LastName;
            await newUser.Save();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <IActionResult> Generate(string siteUrl)
        {
            try
            {
                var url     = new Uri(siteUrl);
                var sitemap = new SiteMap();
                var doc     = _sitemaps.Documents.FirstOrDefault(d => d.Data.Url.AbsoluteUri == url.AbsoluteUri);
                if (doc == null)
                {
                    doc = _sitemaps.New();
                    await sitemap.GenerateAsync(url);

                    await doc.SyncUpdate(sitemap);
                }
                return(RedirectToAction("GetByUrl", new { siteUrl = siteUrl }));
            }
            catch (UriFormatException)
            {
                TempData["ErrorMessage"] = "Invalid URL!";
                return(RedirectToAction("Index"));
            }
        }