コード例 #1
0
        public async Task <IActionResult> Comment(int id, string text, string vote)
        {
            // Change vote
            int _vote = -1;

            if (Int32.TryParse(vote, out _vote))
            {
                await db.ChangeVoteAsync(id, (int)TempData.Peek("id"), _vote);
            }
            // Add comment
            var userId  = (int)TempData.Peek("id");
            var comment = new Comments.Comment()
            {
                UserId = userId, ProductId = id, Text = text
            };

            if (!await db.IsCommentedAsync((int)TempData.Peek("id"), id))
            {
                await db.AddCommentAsync(comment);
            }
            return(RedirectToAction($"Get/{id}"));
        }