public async Task SaveAsync(User User) { using (var db = new PokerTimeContext()) { await db.Users.AddAsync(User); await db.SaveChangesAsync(); } }
public async Task SaveAsync(Post post) { using (var db = new PokerTimeContext()) { db.Users.Attach(post.Author); await db.Posts.AddAsync(post); await db.SaveChangesAsync(); } }
public IEnumerable <Post> GetAllWithImages() { using (var db = new PokerTimeContext()) { return(db.Posts .Include(p => p.Image) .OrderByDescending(p => p.CreatedDate) .ToList()); } }
public Task <User> FindByEmailAndPassword(string email, string password) { using (var db = new PokerTimeContext()) { return(db.Users .Where(u => u.Email.Equals(email) && u.Password.Equals(password)) .Include(u => u.Image) .FirstOrDefaultAsync()); } }