コード例 #1
0
ファイル: LotsController.cs プロジェクト: Forbzz/Auction
        public async Task <IActionResult> CreateComment(int pbId, string comment)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            Comments comm = new Comments
            {
                CarLotId = pbId,
                User     = user,
                Content  = comment,
                CarLot   = carLotsRepository.GetLotDB(pbId)
            };

            if (ModelState.IsValid)
            {
                commRep.AddComm(comm);
            }
            return(RedirectToAction("CommentsList", new { id = pbId }));
        }
コード例 #2
0
        public async Task <IActionResult> CreateComment(int pbId, string comment)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            Comment comm = new Comment
            {
                ItemId       = pbId,
                Author       = user,
                Text         = comment,
                Item         = _whiskyRepository.GetWhiskyById(pbId),
                CreationDate = DateTime.Now,
                ItemTheme    = "Whisky"
            };

            if (ModelState.IsValid)
            {
                _commentRepository.AddComm(comm);
            }
            return(RedirectToAction("CommentsList", new { id = pbId }));
        }