public void insert(Comment comment) { ForumContext context = getContext(); context.Comment.Add(comment); context.SaveChanges(); }
public List <Comment> get(int topicId) { ForumContext context = getContext(); List <Comment> commentLst = context.Comment.Where(c => c.TopicId == topicId).ToList(); return(commentLst); }
public int count(string id) { ForumContext context = getContext(); int count = context.User.Where(user => user.Id == id).Count(); return(count); }
public void insert(User user) { ForumContext context = getContext(); context.User.Add(user); context.SaveChanges(); }
public User get(string id, string password) { ForumContext context = getContext(); User user = context.User.Where(u => u.Id == id && u.Password == password).SingleOrDefault(); return(user); }
public List <User> get() { ForumContext context = getContext(); List <User> userLst = context.User.ToList(); return(userLst); }
public List <Topic> get(string description) { using (var context = new ForumContext()) { List <Topic> topic = context.Topic.Where(t => t.Description.Contains(description)).OrderByDescending(t => t.Id).ToList(); context.Dispose(); return(topic); } }
public Topic get(int id) { using (var context = new ForumContext()) { Topic topic = context.Topic.Where(t => t.Id == id).Single(); context.Dispose(); return(topic); } }
public List <Topic> get() { using (var context = new ForumContext()) { List <Topic> topicLst = context.Topic.OrderByDescending(t => t.Id).ToList(); context.Dispose(); return(topicLst); } }
public void insert(Topic topic) { using (var context = new ForumContext()) { context.Topic.Add(topic); context.SaveChanges(); context.Dispose(); } }
protected static ForumContext getContext() { if (context == null) { context = new ForumContext(); return(context); } return(context); }