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; }
private void detach_NewsVotes(NewsVote entity) { this.SendPropertyChanging(); entity.News = null; }
private void attach_NewsVotes(NewsVote entity) { this.SendPropertyChanging(); entity.News = this; }
partial void DeleteNewsVote(NewsVote instance);
partial void UpdateNewsVote(NewsVote instance);
partial void InsertNewsVote(NewsVote instance);