You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Sevomin.Models.Repositories
  7. {
  8. public class UserRepository : IUserRepository
  9. {
  10. #region Singleton
  11. private static UserRepository member;
  12. private static object locker = new object();
  13. private UserRepository()
  14. {
  15. }
  16. static UserRepository()
  17. {
  18. lock (locker)
  19. {
  20. UserRepository.member = new UserRepository();
  21. }
  22. }
  23. public static UserRepository Current
  24. {
  25. get
  26. {
  27. return UserRepository.member;
  28. }
  29. }
  30. #endregion
  31. public User FindWithConfirmationCode(string code)
  32. {
  33. return SevominDbContext.Current.Users.FirstOrDefault(u => u.ConfirmationCode == code);
  34. }
  35. public void Add(User entity)
  36. {
  37. throw new NotImplementedException();
  38. }
  39. public User Find(string identifier)
  40. {
  41. return SevominDbContext.Current.Users.FirstOrDefault(u => u.UserName.ToLower() == identifier.ToLower());
  42. }
  43. public void Delete(User entity)
  44. {
  45. throw new NotImplementedException();
  46. }
  47. public void Save()
  48. {
  49. SevominDbContext.Current.SaveChanges();
  50. }
  51. }
  52. }