Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class UserRepository : IUserRepository
  2. {
  3. readonly TinRollContext context;
  4. public UserRepository(TinRollContext context)
  5. {
  6. this.context = context;
  7. }
  8. public async Task<User> CreateUserAsync(User user)
  9. {
  10. await context.Users.AddAsync(user);
  11. await context.SaveChangesAsync();
  12. return user;
  13. }
  14.  
  15. public async Task<User> GetUserAsync(int id)
  16. {
  17. return await context.Users.FirstOrDefaultAsync(u => u.Id == id);
  18. }
  19.  
  20. public async Task<IEnumerable<User>> GetUsersAsync()
  21. {
  22. return await context.Users.ToListAsync();
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement