Example #1
0
 public bool LikeAnswer(AnswerModel model, int countLike)
 {
     try
     {
         var sql = string.Format(@"UPDATE [dbo].[uSomeForumReply] SET likeCount='{0}',LikeUsers='{2}' WHERE id ='{1}'", countLike, model.ID, model.LikeUsers);
         _dataHelper.ExecuteNonQuery(sql);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #2
0
 public bool MarkAsAnswer(AnswerModel model)
 {
     try
     {
         var sql = string.Format(@"UPDATE [dbo].[uSomeForumReply] SET markAsAnswer='{0}' WHERE contentId ='{1}';UPDATE [dbo].[uSomeForumReply] SET markAsAnswer='{2}' WHERE id ='{3}'", false, model.ContentId, model.MarkAsAnswer, model.ID);
         _dataHelper.ExecuteNonQuery(sql);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #3
0
 bool Update(AnswerModel model, out int recentId)
 {
     recentId = model.ID;
     try
     {
         var sql = string.Format(@"UPDATE [dbo].[uSomeForumReply] SET comment ='{0}', isPublic='{1}',markAsAnswer='{2}' WHERE ID ='{3}'", model.Comment, model.IsPublic, model.MarkAsAnswer, model.ID);
         _dataHelper.ExecuteNonQuery(sql);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #4
0
 bool Add(AnswerModel model, out int recendId)
 {
     try
     {
         var cmd = string.Format(@"INSERT INTO [dbo].[uSomeForumReply] ([contentId],[userId],[comment],[isPublic]) VALUES
                                 ('{0}','{1}','{2}','{3}');select Scope_Identity()", model.ContentId, model.UserId, model.Comment, model.IsPublic);
         recendId = _dataHelper.ExecuteScalar(cmd);
         return(true);
     }
     catch (Exception ex)
     {
         recendId = -1;
         return(false);
     }
 }
Example #5
0
        public AnswerModel GetAnswerModel(string condition)
        {
            var answerList  = GetAnswersByCondition(condition);
            var answerModel = new AnswerModel();

            foreach (var answer in answerList)
            {
                answerModel.ID           = answer.ID;
                answerModel.Comment      = answer.Comment;
                answerModel.UserId       = answer.UserId;
                answerModel.IsPublic     = answer.IsPublic;
                answerModel.MarkAsAnswer = answer.MarkAsAnswer;
                answerModel.ContentId    = answer.ContentId;
                answerModel.CreatedOn    = answer.CreatedOn;
                answerModel.likeCount    = answer.likeCount;
                answerModel.LikeUsers    = answer.LikeUsers;
            }
            return(answerModel);
        }
        /// <summary>
        /// Posting answer for the question in forum
        /// </summary>
        /// <param name="model">model of the question</param>
        /// <returns></returns>
        public ActionResult PostForumAnswer(AnswerModel model)
        {
            try
            {
                // model.ContentId = int.Parse(questionId);
                Member currentMember = Member.GetCurrentMember();
                model.UserId  = currentMember.Id;
                model.Comment = model.Comment.Replace("'", "''");
                var recendId = 0;
                if (new Answer().Save(model, out recendId))
                {
                    feedbackMsg = (umbraco.library.GetDictionaryItem("fbOnAnswerPostingInForum") != null && umbraco.library.GetDictionaryItem("fbOnAnswerPostingInForum") != "")
                                ? umbraco.library.GetDictionaryItem("fbOnAnswerPostingInForum")
                                : "Thank you for your answer";
                    var logComment = "Reply discussion";
                    if (model.ID != 0)
                    {
                        logComment = "Updated  " + logComment;
                    }
                    var logModel = new LogModel
                    {
                        UserId     = int.Parse(currentMember.Id.ToString()),
                        NodeId     = recendId,
                        LogHeader  = "Forum Post",
                        LogComment = logComment,
                        TableName  = "uSomeForumReply"
                    };

                    new LogHelper().Save(logModel);
                    result = "success";
                    var member = _memberService.GetById(model.UserId);
                    int questionPoint;
                    new Question().GetAnswerPoint(out questionPoint);
                    try
                    {
                        member.Properties["points"].Value = int.Parse(member.Properties["points"].Value.ToString()) + questionPoint;
                    }
                    catch (Exception ex)
                    {
                        member.Properties["points"].Value = 1;
                    }
                    _memberService.Save(member);
                    try
                    {
                        var parentEmailTemplateNodeId = Convert.ToInt16(Request.Form["parentEmailTemplateNodeId"].ToString());
                        var emailTemplateNodeId       = Convert.ToInt16(Request.Form["emailTemplateNodeId"].ToString());

                        var parentEmailTemplate = contentService.GetById(parentEmailTemplateNodeId);
                        var ForumFollowerModel  = new ForumFollowerMailModel();
                        ForumFollowerModel.FromEmail = parentEmailTemplate.Properties["fromEmail"].Value.ToString();
                        var bccEmail   = parentEmailTemplate.Properties["bCCEmail"].Value.ToString();
                        var adminEmail = parentEmailTemplate.Properties["adminEmail"].Value.ToString();


                        var emailTemplate = contentService.GetById(emailTemplateNodeId);
                        ForumFollowerModel.MailSubject = emailTemplate.Properties["subject"].Value.ToString();
                        var mailBody = emailTemplate.Properties["mailBody"].Value.ToString();

                        ForumFollowerModel.Message   = mailBody.Replace("#reply#", model.Comment);
                        ForumFollowerModel.ForumId   = model.ContentId;
                        ForumFollowerModel.TransType = "Ans";
                        var _forumFollower = new ForumFollowers();
                        _forumFollower.FollowersMailSend(ForumFollowerModel);
                    }
                    catch (Exception)
                    { }
                }
            }
            catch (Exception ex)
            {
                feedbackMsg = umbraco.library.GetDictionaryItem("errMsgOnAnswerPostingInForum") != ""
                               ? umbraco.library.GetDictionaryItem("errMsgOnAnswerPostingInForum") : "Error on posting answer. Please Login For Posting Answer.";
                result = "fail";
                Log.ErrorLog("Error in saving forum answer(" + ex.Message + ")");
            }
            return(Json(new { result = result, message = feedbackMsg }));
        }