示例#1
0
        public void PostWithCommentTest()
        {
            m.Post post = new m.Post();
            post.Key = "PostWithCommentTest";
            post.Title = "Post With Comment Test";
            post.Content = "This is a post that will have comments.";
            post.Save();

            post.Comments = new List<Model.Comment>();

            m.Comment comment = null;

            for (int pass = 1; pass < 4; pass++)
            {
                comment = new m.Comment();
                comment.PostID = post.ID;
                comment.Number = pass;
                comment.Content = string.Format("this is comment number {0}.", pass);
                comment.Save();

                post.Comments.Add(comment);

                AssertGoodRead(comment, comment.ID);
            }
            Assert.IsTrue(post.Comments.Count == 3, "Wrong number of comments in post");

            m.Post readPost = m.Post.Get(post.Key);
            Assert.IsTrue(readPost.Comments.Count == 3, "Wrong number of comments in readPost");
            for (int pass = 1; pass < 4; pass++)
            {
                AssertAreEqual(post.Comments[pass - 1], readPost.Comments[pass - 1]);
            }
        }
示例#2
0
 public CommentViewModel(Comment model)
 {
     Id = model.CommentInfo.Id;
     _model = model;
     _model.Refreshed += model_Refreshed;
     var tsk = Refresh();
 }
示例#3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Comment temp = new Comment();
     temp.Comment_nm = txtbComment.Text.Trim();
     temp.Dimension_id = int.Parse(ddlDimension.SelectedValue);
     temp.Posion_id = int.Parse(ddlPosition.SelectedValue);
     temp.Region_id = int.Parse(ddlRegion.SelectedValue);
     temp.Report_part_id = int.Parse(ddlReportPart.SelectedValue);
     commentBll.Add(temp);
 }
        public int AddNew(Comment comment, string userId)
        {
            comment.CreatedOn = DateTime.Now;
            comment.UserId = userId;

            this.comments.Add(comment);
            this.comments.SaveChanges();

            return comment.Id;
        }
示例#5
0
        public void CreateAndGetTest()
        {
            m.Comment comment = new m.Comment();
            comment.PostID = 1;
            comment.Number = 1;
            comment.Content = "this is a comment for the CreateAndGetTest.";
            comment.Save();

            Assert.IsFalse(comment.ID == -1, "Comment ID should not be -1 after insert.");

            AssertGoodRead(comment, comment.ID);
        }
示例#6
0
 protected void btnSayIt_Click(object sender, EventArgs e)
 {
     if (commentContent.Text.Length > 0)
     {
         Comment comment = new Comment();
         comment.PostID = Convert.ToInt32(commentPostId.Value);
         comment.Number = Convert.ToInt32(commentNumber.Value);
         comment.Content = commentContent.Text;
         comment.Save();
         Response.Redirect(string.Format("view.aspx?id={0}", comment.PostID));
     }
 }
示例#7
0
        private void SaveComment()
        {
            int postId = Convert.ToInt32(Request["comment.post_id"]);

            if (string.IsNullOrEmpty(Request["comment.content"])) Response.Redirect(string.Format("view.aspx?id={0}", postId));

            Comment comment = new Comment();
            comment.PostID = postId;
            comment.Number = Convert.ToInt32(Request["comment.number"]);
            comment.Content = Request["comment.content"];
            comment.Save();

            Response.Redirect(string.Format("view.aspx?id={0}", postId));
        }
示例#8
0
		private static IList<Comment> ProcessComments(string file, IDictionary<Guid, Post> posts)
		{
			IList<Comment> comments = new List<Comment>();
			XmlDocument xdoc = GetXmlDocument(file);
			XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdoc.NameTable);
			namespaceManager.AddNamespace("das", "urn:newtelligence-com:dasblog:runtime:data");
			foreach (XmlNode node in xdoc.SelectNodes("/das:DayExtra/das:Comments/das:Comment", namespaceManager))
			{
				Xml xml = new Xml(node, namespaceManager);
				Comment comment = new Comment();
				comment.Created = xml.GetDate("das:Created/text()");
				comment.Modified = xml.GetDate("das:Modified/text()");
				comment.Email = xml.GetString("das:AuthorEmail/text()");
				comment.Author = xml.GetString("das:Author/text()");
				comment.HomePage = xml.GetString("das:AuthorHomepage/text()");
				comment.CommentId = xml.GetGuid("das:EntryId/text()");
				Guid guid = xml.GetGuid("das:TargetEntryId/text()");
				comment.Post = posts[guid];
				comment.Content = xml.GetString("das:Content/text()");
				comments.Add(comment);
			}
			return comments;
		}
 public void Update(Comment comment)
 {
     Context.Entry(comment).State = EntityState.Modified;
     Context.SaveChanges(); // todo move this line out of here.
 }
 public void Add(Comment comment)
 {
     Context.Comments.Add(comment);
     Context.SaveChanges(); // todo move this line out of here.
 }
 public void Delete(Comment comment)
 {
     Context.Comments.Remove(comment);
     Context.SaveChanges(); // todo move this line out of here.
 }
示例#12
0
 public bool AddComment(Comment comment)
 {
     if (comment == null) return false;
     _comments.AddLast(comment);
     float newAvg = _comments.Aggregate<Comment, float>(0, (current, c) => current + c.Rating);
     averageRate = newAvg / _comments.Count;
     return true;
 }
        public ActionResult Comment(Comment comment, string url)
        {
            if (!ModelState.IsValid) return RedirectToAction("Detailed", new {id = comment.AdId});

            if (!_advertiselogic.AddCommentary(comment))
            {
                ModelState.AddModelError("", "Não foi possível enviar o email.");
                return RedirectToAction("Detailed/" + comment.AdId);
            }

            Advert advert = _advertiselogic.GetAdvert(comment.AdId);
            User owner = _userLogic.GetUserById(advert.AdvertiseOwner);

            MailMessage mail = new MailMessage();
            mail.To.Add(owner.Email);

            User activeUser = _userLogic.GetUserById(User.Identity.Name);
            mail.From = new MailAddress(activeUser.Email);
            mail.Subject = "Comentário sobre o seu carro: " + advert.Brand + " " + advert.Model;

            string Body = comment.Username + " deu " + comment.Rating +" estrelas ao seu carro!<br>";
            if (@Request.Url != null)
                Body += url + "<br><br>";
            Body += comment.Message;
            mail.Body = Body;

            if (!_advertiselogic.sendMail(mail))
                ModelState.AddModelError("", "Não foi possível enviar o email.");

            return RedirectToAction("Detailed/" + comment.AdId);
        }
 public bool AddCommentary(Comment com)
 {
     return _dataAccess.AddComment(com);
 }
示例#15
0
        public void UpdateTest()
        {
            m.Comment comment = new m.Comment();
            comment.PostID = 1;
            comment.Number = 2;
            comment.Content = "this is a comment for the UpdateTest.";
            comment.Save();

            Assert.IsFalse(comment.ID == -1, "Comment ID should not be -1 after insert.");

            AssertGoodRead(comment, comment.ID);

            comment.Content = "Change the content for the update test document";
            comment.Save();

            AssertGoodRead(comment, comment.ID);
        }
 public void UpdateComment(Comment entity)
 {
     this.comments.Update(entity);
 }
示例#17
0
        private bool ImportComment(string xlsFileNm)
        {
            try
            {
                if (!File.Exists(xlsFileNm)) return false;

                int posID = Int32.Parse(ddlPosition.SelectedItem.Value);
                Workbook book = Workbook.Load(xlsFileNm);

                PositionBLL posBLL = new PositionBLL();
                DimensionBLL dimBLL = new DimensionBLL();
                CommentBLL comBLL = new CommentBLL();
                Comment com = new Comment();

                DataSet dimDS = dimBLL.GetDimensionAll();
                DataSet posDS = posBLL.GetPositionAll(string.Empty);

                comBLL.DelAllComment(posID);//删除与此岗位相关的所有评语。

                foreach (Worksheet sheet in book.Worksheets)
                {
                    string sheetNm = sheet.Name.Trim();
                    int dimID = -1;//在这里加断点可以监视单个维度的导入情况

                    foreach (DataRow row in dimDS.Tables[0].Rows)
                    {
                        if (row["dimension_name"].ToString().Equals(sheetNm))
                        {
                            dimID = Int32.Parse(row["dimension_id"].ToString().Trim());
                            break;
                        }
                    }
                    for (int rowIndex = sheet.Cells.FirstRowIndex + 1;//忽略第一行(标题行)
                        rowIndex <= sheet.Cells.LastRowIndex; rowIndex++)
                    {
                        Row row = sheet.Cells.GetRow(rowIndex);
                        com.Posion_id = posID;
                        com.Dimension_id = dimID;

                        string score_region = row.GetCell(0).StringValue.Trim();
                        if (score_region.Equals("偏高"))
                        {
                            com.Region_id = 1;
                        }
                        else if (score_region.Equals("适配"))
                        {
                            com.Region_id = 2;
                        }
                        else if (score_region.Equals("稍低"))
                        {
                            com.Region_id = 3;
                        }
                        else if (score_region.Equals("偏低"))
                        {
                            com.Region_id = 4;
                        }

                        for (int i = 1; i < sheet.Cells.LastColIndex + 1; i++)
                        {
                            com.Report_part_id = i;
                            com.Comment_nm = row.GetCell(i).StringValue.Trim();
                            comBLL.Add(com);
                        }
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
示例#18
0
 private static Comment FromReader(IDataReader reader)
 {
     Comment comment = new Comment();
     comment.ID = dm.ConvertIntColumn(reader, "id");
     comment.PostID = dm.ConvertIntColumn(reader, "post_id");
     comment.Number = dm.ConvertIntColumn(reader, "number");
     comment.Content = dm.ConvertStringColumn(reader, "content");
     comment.Created = (DateTime)reader["created"];
     return comment;
 }
示例#19
0
 public void Add(Comment pComment)
 {
     _arrayInternal.Add(pComment);
 }
        public Comment Create(string content, string authorEmail, string userId, int realEstateId)
        {
            var comment = new Comment()
            {
                Content = content,
                RealEstateId = realEstateId,
                CreatedOn = DateTime.Now,
                AuthorEmail = authorEmail,
                UserId = userId
            };

            this.comments.Add(comment);
            this.comments.SaveChanges();

            return comment;
        }