Beispiel #1
0
 public User GetUser(Guid id)
 {
     using (var context = new SuperForumContext())
     {
         return(context.Set <User>().Find(id));
     }
 }
Beispiel #2
0
 public IList <Topic> GetTopics()
 {
     using (var context = new SuperForumContext())
     {
         return(context.Topics.Include(t => t.User).ToList());
     }
 }
Beispiel #3
0
 public Topic GetTopic(Guid?id)
 {
     using (var context = new SuperForumContext())
     {
         return(GetTopics().Where(t => t.Id == id).FirstOrDefault());
     }
 }
Beispiel #4
0
 public void Delete(Guid id)
 {
     using (var context = new SuperForumContext())
     {
         context.Entry(GetUser(id)).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Beispiel #5
0
 public void Update(User user)
 {
     using (var context = new SuperForumContext())
     {
         context.Entry(user).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #6
0
 public List <User> GetUsers()
 {
     using (var context = new SuperForumContext())
     {
         return((from user in context.Users
                 select user).ToList());
     }
 }
Beispiel #7
0
 public void Delete(Guid id)
 {
     using (var context = new SuperForumContext())
     {
         context.Entry(GetTopic(id)).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Beispiel #8
0
 public void Update(Topic topic)
 {
     using (var context = new SuperForumContext())
     {
         context.Entry(topic).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #9
0
 public void Create(Topic topic)
 {
     using (var context = new SuperForumContext())
     {
         context.Entry(topic).State = System.Data.Entity.EntityState.Added;
         context.SaveChanges();
     }
 }
Beispiel #10
0
 public User GetUserByName(string name)
 {
     using (var context = new SuperForumContext())
     {
         var query = (from user in context.Users
                      where user.Name == name
                      select user);
         return(query.First());
     }
 }