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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 public void Add(Comments comments)
 {
     _appDbContext.Add(comments);
 }
Exemplo n.º 4
0
 public void Create(Comment item)
 {
     db.Add(item);
 }