public async Task <IActionResult> Create([Bind("Id,Content")] Comment comment) { if (ModelState.IsValid) { _context.Add(comment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(comment)); }
public async Task <IActionResult> Create([Bind("Content")] Comments comment) { var itemId = TempData["itemId"] as string; if (ModelState.IsValid) { DateTime today = DateTime.Now; var user = await userManager.GetUserAsync(User); comment.Id = user.Id + today.ToString(); comment.Author = user.Id; comment.ItemId = itemId; _context.Add(comment); await _context.SaveChangesAsync(); return(RedirectToAction("Details", "Items", new { id = itemId })); } return(View(comment)); }
public void Add(Comments comments) { _appDbContext.Add(comments); }
public void Create(Comment item) { db.Add(item); }