public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Content")] Article article) { if (ModelState.IsValid) { List <ContentTag> contentTags = await _context.ContentTags.ToListAsync(); foreach (var item in contentTags) { string isChecked = Request.Form[item.Tag]; if (isChecked != "false") { article.ArticleHasTags.Add(new ArticleHasTag() { Article = article, ArticleId = article.Id, ContentTag = item, ContentTagId = item.Id }); } } _context.Add(article); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(article)); }
public async Task <IActionResult> Create([Bind("Id,Tag")] ContentTag contentTag) { if (ModelState.IsValid) { _context.Add(contentTag); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contentTag)); }
public async Task <IActionResult> Create([Bind("Id,Email,Password,IsAdmin")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }