public async Task<IActionResult> Edit(int id, [Bind("BlogId,UserFishId,BlogTitle,Content,BlogDate")] PublicBlog publicBlog) { if (id != publicBlog.BlogId) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(publicBlog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PublicBlogExists(publicBlog.BlogId)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } ViewData["UserFishId"] = new SelectList(_context.Userfish, "UserFishId", "FishLength", publicBlog.UserFishId); return View(publicBlog); }
public async Task<IActionResult> Create([Bind("BlogId,UserFishId,BlogTitle,Content,BlogDate")] PublicBlog publicBlog) { if (ModelState.IsValid) { _context.Add(publicBlog); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } ViewData["UserFishId"] = new SelectList(_context.Userfish, "UserFishId", "UserFishId", publicBlog.UserFishId); return View(publicBlog); }