public async Task <IActionResult> Create([Bind("TagId,Name")] Tag tag) { if (ModelState.IsValid) { _context.Add(tag); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public async Task <IActionResult> Create([Bind("PostId,Title,Content,BlogId")] Post post) { if (ModelState.IsValid) { _context.Add(post); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Blogs", new { id = post.BlogId })); } ViewData["BlogId"] = new SelectList(_context.Blogs, "BlogId", "BlogId", post.BlogId); return(View(post)); }
public async Task <IActionResult> Create([Bind("BlogImageId,Image,Caption,BlogForeignKey")] BlogImage blogImage) { if (ModelState.IsValid) { _context.Add(blogImage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BlogForeignKey"] = new SelectList(_context.Blogs, "BlogId", "BlogId", blogImage.BlogForeignKey); return(View(blogImage)); }
public async Task <IActionResult> Create([Bind("PostId,TagId")] PostTag postTag) { if (ModelState.IsValid) { _context.Add(postTag); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PostId"] = new SelectList(_context.Posts, "PostId", "PostId", postTag.PostId); ViewData["TagId"] = new SelectList(_context.Tags, "TagId", "TagId", postTag.TagId); return(View(postTag)); }