Ejemplo n.º 1
0
        public ActionResult AddComment(int listId, ListItemCommentModel model)
        {
            var list = listService.GetById(listId);

            if (list == null || !list.EnabledComments)
            {
                return(new HttpNotFoundResult());
            }

            if (ModelState.IsValid && IsValidUrl(model.Website))
            {
                var comment = new ListComment
                {
                    Name        = model.Name,
                    Email       = model.Email,
                    Website     = model.Website,
                    Comments    = model.Comments,
                    ListId      = listId,
                    ListItemId  = model.ListItemId,
                    CreatedDate = DateTime.UtcNow,
                    IsApproved  = list.AutoModeratedComments,
                    IPAddress   = ClientIPAddress
                };

                listItemCommentService.Insert(comment);
            }

            return(Redirect(Request.UrlReferrer == null
                ? Url.Content("~/")
                : Request.UrlReferrer.ToString()));
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         ListComment.DataSource = new TafsirLib.Comments().Load(false);
         ListComment.DataBind();
     }
     catch (Exception)
     {
         //var err = ex.Message;
     }
 }
Ejemplo n.º 3
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < ListNew.Count; i++)
            {
                ListNew.Remove(ListNew[i]);
                i--;
            }
            for (int i = 0; i < ListComment.Count; i++)
            {
                ListComment.Remove(ListComment[i]);
                i--;
            }
            labelComment.Text = "";

            using (NewsContext NewsTable = new NewsContext())
            {
                foreach (var i in NewsTable.NewT)
                {
                    ListNew.Add(i);
                }

                foreach (var i in NewsTable.CommentT)
                {
                    ListComment.Add(i);
                }

                if (ListNew.Count != 0)
                {
                    labelHead.Text = ListNew[0].Head;
                    labelText.Text = ListNew[0].Basis;
                    Count          = 0;
                }
            }

            foreach (var i in ListComment)
            {
                if (i.IdNew == ListNew[Count])
                {
                    labelComment.Text += i.Text + '\n' + '\n';
                }
            }
        }