コード例 #1
0
        public async Task <IActionResult> Create(News news)
        {
            if (ModelState.IsValid)
            {
                news.AuthorId = _userManager.GetUserId(User);

                if (await _newsRepository.SaveAllAsync(news))
                {
                    _fileService.AddNewsJsonFile(news);

                    return(RedirectToAction("Index"));
                }
            }
            return(View(news));
        }