Ejemplo n.º 1
0
        public ActionResult ManageFlags(string Type, string Action, int id)
        {
            if (Type == "Picture")
            {
                Picture pic = PictureManager.GetPictureById(id);
                if (Action == "unflag")
                {
                    pic.IsFlagged = false;
                    PictureManager.EditPictureFlagged(pic);
                }
                else
                {
                    PictureManager.DeletePicture(pic);
                }
            }
            else
            {
                Comment comment = CommentsManage.GetCommentById(id);
                if (Action == "unflag")
                {
                    comment.IsFlagged = false;
                    CommentsManage.EditCommentFlagged(comment);
                }
                else
                {
                    CommentsManage.DeleteComment(comment);
                }
            }

            return(RedirectToAction("ManageFlags"));
        }
Ejemplo n.º 2
0
        public JsonResult LikeVote(string JsonResult)
        {
            string  result = JsonResult;
            Vote    vote   = null;
            JObject jobj   = JObject.Parse(JsonResult);

            vote = VoteManager.getVotedByComment_idAndParticipantId(Convert.ToInt32(jobj["CommentId"]), Convert.ToInt32(jobj["ParticipantId"]));
            int comment_id     = Convert.ToInt32(jobj["CommentId"]);
            int partucipant_id = Convert.ToInt32(jobj["ParticipantId"]);
            int ck             = Convert.ToInt32(jobj["isLike"]);

            if (vote == null)
            {
                vote               = new Vote();
                vote.CommentId     = comment_id;
                vote.ParticipantId = partucipant_id;

                vote.IsLike = null;
                if (ck == -1)
                {
                    vote.IsLike = null;
                }
                else if (ck == 0)
                {
                    vote.IsLike = false;
                }
                else if (ck == 1)
                {
                    vote.IsLike = true;
                }
                VoteManager.AddVoted(vote);
                VoteManager.SumVotedScore(Convert.ToInt32(jobj["CommentId"]));
            }
            else
            {
                vote.IsLike = null;
                if (ck == -1)
                {
                    vote.IsLike = null;
                }
                else if (ck == 0)
                {
                    vote.IsLike = false;
                }
                else if (ck == 1)
                {
                    vote.IsLike = true;
                }
                VoteManager.EditVotedIslike(vote);
                VoteManager.SumVotedScore(Convert.ToInt32(jobj["CommentId"]));
            }
            Comment comment = CommentsManage.GetCommentById(Convert.ToInt32(jobj["CommentId"]));
            String  res     = comment.VoteScore + "";

            String[] str = new String[2];
            str[0] = res;
            str[1] = ck + "";
            return(Json(str, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public JsonResult GiveFlagged(string JsonFlag)
        {
            string  result  = JsonFlag;
            JObject jobj    = JObject.Parse(result);
            Comment comment = CommentsManage.GetCommentById(Convert.ToInt32(jobj["CommentId"]));

            comment.IsFlagged = true;
            CommentsManage.EditCommentFlagged(comment);
            String res = "Flag Comment Success";

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public ActionResult SubmitComment(Comment comment)
        {
            comment.IsFlagged = false;
            DateTime t = DateTime.Now;

            comment.IsFlagged = false;
            comment.Time      = t;
            comment.VoteScore = 0;
            CommentsManage.AddComment(comment);
            //comment = CommentsManage.GetCommentByDateTime(t);
            //comment = CommentsManage.GetCommentById(comment.Id);

            //Vote vote = new Vote();
            //vote.CommentId = comment.Id;
            //vote.ParticipantId = comment.;
            //vote.IsLike = null;
            //VoteManager.AddVoted(vote);

            return(RedirectToAction("PictureDetail", new { id = comment.PictureId }));
        }
Ejemplo n.º 5
0
        // GET: Picture
        public ActionResult PictureDetail(int id)
        {
            ViewBag.picture = PictureManager.GetPictureById(id);


            if (Session["participantID"] != null)
            {
                ViewBag.Participant = ParticipantManager.GetById(Convert.ToInt32(Session["participantID"]));
            }

            string listSort = Request.QueryString["ListSort"];//check if user prompted a type of sorting

            if (listSort == null || listSort == "Recent")
            {
                ViewBag.comments = CommentsManage.SortByRecent(CommentsManage.GetCommentByPictureId(id));
            }
            else
            {
                ViewBag.comments = CommentsManage.SortByPopular(CommentsManage.GetCommentByPictureId(id));//popular sorting, most votes
            }

            return(View());
        }
Ejemplo n.º 6
0
 public ActionResult ManageFlags()
 {
     ViewBag.FlaggedPics     = PictureManager.GetFlagged();
     ViewBag.FlaggedComments = CommentsManage.GetFlagged();
     return(View());
 }