Beispiel #1
0
        public async Task <IActionResult> OnPostDeleteAsync()
        {
            var article = await Service.FindByIdAsync(ArticleId.ToString());

            if (article == null)
            {
                return(NotFound());
            }

            var result = await Service.DeleteAsync(article);

            if (result.Successfull)
            {
                if (PageId == null)
                {
                    return(RedirectToPage("/Articles/Index"));
                }

                return(RedirectToPage("/WebPage/Articles/Index", new { pageId = PageId }));
            }

            foreach (var error in result.Errors)
            {
                ModelState.AddModelError(string.Empty, error.Message);
            }

            return(await OnGetAsync(article.Id));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostUpdateAsync()
        {
            var article = await Service.FindByIdAsync(ArticleId.ToString());

            if (article == null)
            {
                return(NotFound());
            }

            var formDict = Request.Form.ToDictionary(k => k.Key.ToString(), k => k.Value);

            article.MarkdownText = MarkdownText;
            var result = await Service.UpdateAsync(article, formDict);

            if (result.Successfull)
            {
                return(RedirectToPage(new { id = article.Id }));
            }

            foreach (var error in result.Errors)
            {
                ModelState.AddModelError(string.Empty, error.Message);
            }

            return(await OnGetAsync(article.Id));
        }
Beispiel #3
0
 public String?ConvertNullableFrom(ArticleId?value)
 {
     return(value?.ToString());
 }
Beispiel #4
0
 public String ConvertFrom(ArticleId value)
 {
     return(value.ToString());
 }
Beispiel #5
0
 public async Task Delete()
 {
     await DbHelper.DeleteDocumentAsync(ArticleId.ToString(), Author, CollectionId);
 }