Example #1
0
 public int? VoteForNews( long id, String userName )
 {
     var userId = GetAuthorId( userName );
     var query =
         from v in db.NewsVotes
         where v.news_id == id && v.user_id == userId
         select v;
     if (query.Count() == 0)
     {
         var vote = new NewsVote() { news_id = id, user_id = userId};
         db.NewsVotes.InsertOnSubmit( vote );
         var voteCount = ++db.News.SingleOrDefault( n => n.id == id ).voted_for;
         Save();
         return voteCount;
     }
     return db.News.SingleOrDefault( n => n.id == id).voted_for;
 }
Example #2
0
		private void detach_NewsVotes(NewsVote entity)
		{
			this.SendPropertyChanging();
			entity.News = null;
		}
Example #3
0
		private void attach_NewsVotes(NewsVote entity)
		{
			this.SendPropertyChanging();
			entity.News = this;
		}
Example #4
0
 partial void DeleteNewsVote(NewsVote instance);
Example #5
0
 partial void UpdateNewsVote(NewsVote instance);
Example #6
0
 partial void InsertNewsVote(NewsVote instance);