Beispiel #1
0
        public async Task <ActionResult> Answer(int CommentID, string message)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Challenge());
            }
            if (!string.IsNullOrEmpty(message))
            {
                Answer answer = new Answer()
                {
                    Message    = message,
                    Status     = 1,
                    UserID     = currentUser.UserName,
                    AnswerTime = DateTime.Now,
                };
                _context.Add(answer);
                _context.SaveChanges();
                CommentAnswer commentAnswer = new CommentAnswer()
                {
                    AnswerID  = answer.AnswerID,
                    CommentID = CommentID,
                };
                _context.Add(commentAnswer);
                _context.SaveChanges();
                await _context.SaveChangesAsync();
            }
            return(Redirect(Request.Headers["Referer"].ToString()));
        }
        public async Task <int> EditCommentAnswer(int id, CommentAnswerVM answer)
        {
            var editedAnswer = new CommentAnswer()
            {
                CommentAnswerID   = answer.CommentAnswerID,
                AnswerComment     = answer.Answer,
                ApplicationUserID = answer.UserID
            };

            _unitOfWork.Entry(editedAnswer).State = System.Data.Entity.EntityState.Modified;
            return(await _unitOfWork.SaveAllChangesAsync());
        }
Beispiel #3
0
        public JsonResult CommentAnswer(int id, string comment)
        {
            Comment       yorum     = repoC.GetById(id);
            CommentAnswer newAnswer = new CommentAnswer();

            newAnswer.CommentId = yorum.Id;
            newAnswer.UserId    = HttpContext.User.Identity.GetUserId();
            newAnswer.Content   = comment;
            if (repoComAns.Add(newAnswer))
            {
                return(Json("True", JsonRequestBehavior.AllowGet));
            }
            return(Json("False", JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public bool AddAnswerForComment(int salelistingID, int commentID, CommentDTO answerviewmodel)
        {
            try
            {
                SaleListing salelisting = _saleListingRepository.GetSaleListing(salelistingID);
                Comment     comment     = salelisting.Comments.Single(e => e.ID == commentID);

                CommentAnswer answer = Mapper.Map <CommentDTO, CommentAnswer>(answerviewmodel);

                comment.Answers.Add(answer);
                _saleListingRepository.UpdateSaleListing(salelisting);
                //_log.LogSaleListing(salelisting.Owner.ID, salelisting.ID, eLogSaleListingType.Comment);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }