public User GetUser(Guid id) { using (var context = new SuperForumContext()) { return(context.Set <User>().Find(id)); } }
public IList <Topic> GetTopics() { using (var context = new SuperForumContext()) { return(context.Topics.Include(t => t.User).ToList()); } }
public Topic GetTopic(Guid?id) { using (var context = new SuperForumContext()) { return(GetTopics().Where(t => t.Id == id).FirstOrDefault()); } }
public void Delete(Guid id) { using (var context = new SuperForumContext()) { context.Entry(GetUser(id)).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void Update(User user) { using (var context = new SuperForumContext()) { context.Entry(user).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public List <User> GetUsers() { using (var context = new SuperForumContext()) { return((from user in context.Users select user).ToList()); } }
public void Delete(Guid id) { using (var context = new SuperForumContext()) { context.Entry(GetTopic(id)).State = EntityState.Deleted; context.SaveChanges(); } }
public void Update(Topic topic) { using (var context = new SuperForumContext()) { context.Entry(topic).State = EntityState.Modified; context.SaveChanges(); } }
public void Create(Topic topic) { using (var context = new SuperForumContext()) { context.Entry(topic).State = System.Data.Entity.EntityState.Added; context.SaveChanges(); } }
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()); } }