Beispiel #1
0
        public ActionResult InsertComment(tbl_Comments tComment)
        {
            try
            {
                tComment.Title    = "نظر";
                tComment.Confirm  = false;
                tComment.Date     = DateTime.Now.Date;
                tComment.Family   = "f";
                tComment.DisLike  = 0;
                tComment.Like     = 0;
                tComment.ParentID = 0;
                tComment.Read     = false;
                tComment.IP       = Request.UserHostAddress;


                db.tbl_Comments.Add(tComment);

                if (Convert.ToBoolean(db.SaveChanges()))
                {
                    ViewBag.Style   = "color:green";
                    ViewBag.Message = "نظر ثبت شد";
                }
                else
                {
                    ViewBag.Style   = "color:red";
                    ViewBag.Message = "نظر ثبت نشد";
                }

                return(View("Subject", RepSubject.GetDeatilsSubject(tComment.SubjectID)));
            }
            catch
            {
                return(Content("Error"));
            }
        }
Beispiel #2
0
        public ActionResult CommentReplay(int ParentID, int SubjectID)
        {
            tbl_Comments tComment = new tbl_Comments();

            tComment.SubjectID = SubjectID;
            tComment.ParentID  = ParentID;
            return(PartialView("P_ReplayComment", tComment));
        }
        public string AcceptOrRejectArticleByR(int artId, string articleName, string articleDescription, DateTime dateOfPublish, int userId, int mediaManagerId, int articleStatusId, int articleStateId, string commentContent, int articleCommentId)
        {
            string uArticle = "";

            System.Net.ServicePointManager.DefaultConnectionLimit = 200;
            db.Configuration.ProxyCreationEnabled = false;

            tbl_Article updatedArticle = db.tbl_Article.SingleOrDefault(x => x.Article_Id == artId);
            updatedArticle.Article_Name = articleName;
            updatedArticle.Article_Description = articleDescription;
            updatedArticle.Article_PublishDate = dateOfPublish;
            updatedArticle.User_Id = userId;
            updatedArticle.MedaManager_Id = mediaManagerId;
            updatedArticle.ArticleStatus_Id = articleStatusId;
            if (articleStatusId == 2) //Accepted by Reviewer
            {
                //updatedArticle.Article_State_Id = 2;
                tbl_Workflows currentPosOfWorkflow = db.tbl_Workflows.SingleOrDefault(x => x.User_Id == userId && x.State_Id == updatedArticle.Article_State_Id);
                tbl_Workflows nextPosOfWorkFlow =
                 db.tbl_Workflows.SingleOrDefault(x => x.Workflow_Id == currentPosOfWorkflow.Workflow_Id + 1 && x.User_Id == userId);

                updatedArticle.Article_State_Id = nextPosOfWorkFlow.State_Id;
            }
            else if (articleStatusId == 3) //Rejected by Reviewer
            {
                updatedArticle.Article_State_Id = 4;
            }

            tbl_Comments newComment = new tbl_Comments();
            //if (newComment.ArticleComment_Content == "")
            //if (updatedArticle.ArticleComment_Id == null)
            if(commentContent == null)
            {
                updatedArticle.ArticleComment_Id = null;
            }
            else
            {
                newComment.ArticleComment_Content = commentContent;
                newComment.Article_Id = artId;
                newComment.User_Id = userId;
                db.Entry(newComment).State = EntityState.Added;
                db.SaveChanges();

                updatedArticle.ArticleComment_Id = newComment.ArticleComment_Id;
            }

            db.Entry(updatedArticle).State = EntityState.Modified;
            db.SaveChanges();

            if (uArticle != "")
            {
                return uArticle;
            }
            else
            {
                return null;
            }
        }
        public string AcceptOrRejectArticleByMm(int artId, string articleName, string articleDescription, DateTime dateOfPublish, int userId, int mediaManagerId, int articleStatusId, int articleStateId, string commentContent, int articleCommentId)
        {
            string uArticle = "";

            System.Net.ServicePointManager.DefaultConnectionLimit = 200;
            db.Configuration.ProxyCreationEnabled = false;

            tbl_Article updatedArticle = db.tbl_Article.SingleOrDefault(x => x.Article_Id == artId);
            updatedArticle.Article_Id = artId;
            updatedArticle.Article_Name = articleName;
            updatedArticle.Article_Description = articleDescription;
            updatedArticle.Article_PublishDate = dateOfPublish;
            updatedArticle.User_Id = userId;
            updatedArticle.MedaManager_Id = mediaManagerId;
            updatedArticle.ArticleStatus_Id = articleStatusId;
            if (articleStatusId == 4) //Accepted by Media Manager
            {
                //updatedArticle.Article_State_Id = 2;
                tbl_Workflows currentPosOfWorkflow = db.tbl_Workflows.SingleOrDefault(x => x.User_Id == userId && x.State_Id == updatedArticle.Article_State_Id);
                tbl_Workflows nextPosOfWorkFlow =
                 db.tbl_Workflows.SingleOrDefault(x => x.Workflow_Id == currentPosOfWorkflow.Workflow_Id + 1 && x.User_Id == userId);

                updatedArticle.Article_State_Id = nextPosOfWorkFlow.State_Id;
            }
            else if (articleStatusId == 5) //Rejected by Media Manager
            {
                updatedArticle.Article_State_Id = 4;
            }

            tbl_Comments newComment = new tbl_Comments();
            if (commentContent == null) //If article do not have a comment by a reviewer and
            {                                            //media manager left the article without a comment too
                updatedArticle.ArticleComment_Id = null;
            }
            else
            {
                if (updatedArticle.ArticleComment_Id == null) //If media manager added the first comment to the article
                {
                    newComment.ArticleComment_Content = commentContent;
                    newComment.Article_Id = artId;
                    newComment.User_Id = userId;
                    db.Entry(newComment).State = EntityState.Added;
                    db.SaveChanges();

                    updatedArticle.ArticleComment_Id = newComment.ArticleComment_Id;
                }
                else if (updatedArticle.ArticleComment_Id != null) //If media manager replaced the comment of the reviewer
                {
                    newComment.ArticleComment_Id = Convert.ToInt32(updatedArticle.ArticleComment_Id);
                    newComment.ArticleComment_Content = commentContent;
                    newComment.Article_Id = artId;
                    newComment.User_Id = userId;
                    db.Entry(newComment).State = EntityState.Modified;
                    db.SaveChanges();

                    updatedArticle.ArticleComment_Id = newComment.ArticleComment_Id;
                }
            }
            db.Entry(updatedArticle).State = EntityState.Modified;
            db.SaveChanges();

            if (uArticle != "")
            {
                return uArticle;
            }
            else
            {
                return null;
            }
        }