Exemple #1
0
        public void insert(Comment comment)
        {
            ForumContext context = getContext();

            context.Comment.Add(comment);
            context.SaveChanges();
        }
Exemple #2
0
        public List <Comment> get(int topicId)
        {
            ForumContext   context    = getContext();
            List <Comment> commentLst = context.Comment.Where(c => c.TopicId == topicId).ToList();

            return(commentLst);
        }
Exemple #3
0
        public int count(string id)
        {
            ForumContext context = getContext();
            int          count   = context.User.Where(user => user.Id == id).Count();

            return(count);
        }
Exemple #4
0
        public void insert(User user)
        {
            ForumContext context = getContext();

            context.User.Add(user);
            context.SaveChanges();
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        public List <User> get()
        {
            ForumContext context = getContext();
            List <User>  userLst = context.User.ToList();

            return(userLst);
        }
Exemple #7
0
 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);
     }
 }
Exemple #8
0
 public Topic get(int id)
 {
     using (var context = new ForumContext())
     {
         Topic topic = context.Topic.Where(t => t.Id == id).Single();
         context.Dispose();
         return(topic);
     }
 }
Exemple #9
0
 public List <Topic> get()
 {
     using (var context = new ForumContext())
     {
         List <Topic> topicLst = context.Topic.OrderByDescending(t => t.Id).ToList();
         context.Dispose();
         return(topicLst);
     }
 }
Exemple #10
0
 public void insert(Topic topic)
 {
     using (var context = new ForumContext())
     {
         context.Topic.Add(topic);
         context.SaveChanges();
         context.Dispose();
     }
 }
Exemple #11
0
 protected static ForumContext getContext()
 {
     if (context == null)
     {
         context = new ForumContext();
         return(context);
     }
     return(context);
 }