Пример #1
0
        public void insert(Comment comment)
        {
            ForumContext context = getContext();

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

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

            return(count);
        }
Пример #4
0
        public void insert(User user)
        {
            ForumContext context = getContext();

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

            return(userLst);
        }
Пример #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);
     }
 }
Пример #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);
     }
 }
Пример #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);
     }
 }
Пример #10
0
 public void insert(Topic topic)
 {
     using (var context = new ForumContext())
     {
         context.Topic.Add(topic);
         context.SaveChanges();
         context.Dispose();
     }
 }
Пример #11
0
 protected static ForumContext getContext()
 {
     if (context == null)
     {
         context = new ForumContext();
         return(context);
     }
     return(context);
 }