Пример #1
0
        public async Task <IActionResult> OnPostDataAsync(string id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var article = MapToArticle();

            if (string.IsNullOrEmpty(id))
            {
                await _articlesService.CreateAsync(article);
            }
            else
            {
                await _articlesService.UpdateAsync(article);
            }

            return(RedirectToPage("/admin"));
        }
Пример #2
0
 public async Task <IActionResult> Post([FromBody] CreateArticleRequest request) =>
 (await _articlesService.CreateAsync(CurrentUserId, request.Article))
 .Match <IActionResult>(article => CreatedAtAction(nameof(Post), new { article }), Error);