Example #1
0
        public void SubmitArticle(string url, string title, string owner)
        {
            Article arr = new Article()
            {
                URL = url,
                Title = title,
                Diggers = owner,
                submittedDate = DateTime.Now
            };

            RedditCloneDataContext dc = new RedditCloneDataContext();
            dc.Articles.InsertOnSubmit(arr);
            dc.SubmitChanges();

            var article = (from arr1 in dc.Articles
                          where arr1.URL== url
                          orderby arr1.submittedDate descending
                          select arr1);
            Article arrNew = article.ToList()[0];

            VoteHistory vHis = new VoteHistory()
            {
                articleID = arrNew.id,
                diggers = owner,
                voteChoice=(int)VoteChoiceEnum.UpVote

            };
 //           RedditCloneDataContext dc1= new RedditCloneDataContext();
            dc.VoteHistories.InsertOnSubmit(vHis);
            dc.SubmitChanges();

            
        }
		private void detach_VoteHistories(VoteHistory entity)
		{
			this.SendPropertyChanging();
			entity.UserInfo = null;
		}
 partial void DeleteVoteHistory(VoteHistory instance);
 partial void UpdateVoteHistory(VoteHistory instance);
 partial void InsertVoteHistory(VoteHistory instance);
		private void attach_VoteHistories(VoteHistory entity)
		{
			this.SendPropertyChanging();
			entity.Article = this;
		}
Example #7
0
        private void CastVote(int id, string digger, int voteChoice1)
        {
            RedditCloneDataContext dc = new RedditCloneDataContext();
            VoteHistory vHis = dc.VoteHistories.SingleOrDefault(prop => (prop.diggers == digger && prop.articleID == id));
            if (vHis == null)
            {
                VoteHistory vh = new VoteHistory()
                    {
                        articleID = id,
                        diggers = digger,
                        voteChoice = voteChoice1

                    };
                dc.VoteHistories.InsertOnSubmit(vh);
            }
            else
            {
                vHis.voteChoice = voteChoice1;
            }
            dc.SubmitChanges();
        }