public UserDB Select(string email)
 {
     using (var db = new WasteContext())
     {
         return(db.Users.Where(user => user.Email == email).FirstOrDefault());
     }
 }
 public IEnumerable <UserDB> SelectAll()
 {
     using (var db = new WasteContext())
     {
         return(db.Users.ToList());
     }
 }
 public UserDB Select(string email, string password)
 {
     using (var db = new WasteContext())
     {
         return(db.Users.Where(user => user.Email == email && user.PasswordHash == password).FirstOrDefault());
     }
 }
 public IEnumerable <UserDB> SelectWhere(Func <UserDB, bool> predicate)
 {
     using (var db = new WasteContext())
     {
         return(db.Users.Where(predicate));
     }
 }
 public UserRoleRepository(WasteContext context)
 {
     _context = context;
     _store   = new RoleStore <IdentityRole>(_context)
     {
         DisposeContext = true
     };
     _manager = new RoleManager <IdentityRole>(_store);
 }
 public DiagnosticRepository(WasteContext context, Faker faker)
 {
     _context = context;
     _store   = new UserStore <UserDB>(_context)
     {
         DisposeContext = true
     };
     _manager = new UserManager <UserDB>(_store);
     _faker   = faker;
 }
        public void Add(UserDB user)
        {
            if (user.Id != null)
            {
                throw new ArgumentException("Cannot Add User with Id different from null.");
            }

            user.Created = DateTime.UtcNow;
            using (var db = new WasteContext())
            {
                db.Users.Add(user);
                db.SaveChanges();
            }
        }
        public UserRepository(WasteContext context, Faker faker, IMapper mapper)
        {
            _context = context;

            _store = new UserStore <UserDB>(_context)
            {
                DisposeContext = true
            };
            _manager = new UserManager <UserDB>(_store);

            _faker = faker;

            _mapper = mapper;
        }
        public void Update(UserDB user)
        {
            using (var db = new WasteContext())
            {
                var userInDB = db.Users.Find(user.Id);

                user.Created = userInDB.Created;

                db.Entry(userInDB).CurrentValues.SetValues(user);

                userInDB.Modified = DateTime.UtcNow;

                db.SaveChanges();
            }
        }
Esempio n. 10
0
 public static void WorkWithEF()
 {
     using (WasteContext dbContext = new WasteContext())
     {
         var userDB = new UserDB()
         {
             UserName             = "******",
             Email                = "*****@*****.**",
             EmailConfirmed       = true,
             PasswordHash         = "qwerty",
             SecurityStamp        = "Stamp",
             PhoneNumber          = "+375255024800",
             PhoneNumberConfirmed = true,
             TwoFactorEnabled     = false,
             LockoutEndDateUtc    = null,
             Created              = DateTime.UtcNow,
             Modified             = null
         };
         dbContext.Users.Add(userDB);
         dbContext.SaveChanges();
         Console.WriteLine("Done!");
     }
 }
        public void Delete(UserDB user)
        {
            if (user.Id != null)
            {
                using (var db = new WasteContext())
                {
                    var result = db.Users.Where(f => f.Id == user.Id).FirstOrDefault();

                    if (result != null)
                    {
                        db.Users.Remove(result);
                        db.SaveChanges();
                    }
                    else
                    {
                        throw new ArgumentException($"The User cannot be deleted because User with Id = {user.Id} doesn't exist.");
                    }
                }
            }
            else
            {
                throw new ArgumentException("Cannot delete User with Id = null.");
            }
        }
 public EFTaskRepositry(WasteContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initializes a new instance of DonationRepository.
 /// </summary>
 /// <param name="context">The specific context of WasteContext.</param>
 public DonationRepository(WasteContext context) => _context = context;
 public BarcodeRepository(WasteContext wasteContext)
 {
     _wasteContext = wasteContext;
 }
 public EFTrackRecordRepository(WasteContext context)
     : base(context)
 {
 }
 public EFMessageRepository(WasteContext context)
     : base(context)
 {
 }
 public SocialProfileRepository(WasteContext context) : base(context)
 {
 }
Esempio n. 18
0
 public EFPatternRepository(WasteContext context) : base(context)
 {
 }
 public UserStore(WasteContext context) : base(context)
 {
 }
 protected BaseRepositry(WasteContext context)
 {
     //TODO: To dopracowaæ~!
     _context = context;
     _context.Database.Log = s => Debug.Write(s); //Logging to Output
 }
Esempio n. 21
0
 /// <inheritdoc/>
 public CategoryRepository(WasteContext context) => _context = context;
 public PeriodRepository(WasteContext context) : base(context)
 {
 }
Esempio n. 23
0
 public WasteStatisticRepository(WasteContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Using the context of the WasteContext class through the private field.
 /// </summary>
 /// <param name="context">The specific context of WasteContext</param>
 public ProductRepository(WasteContext context) => _context = context;
 public GroupRepository(WasteContext context)
 {
     _context = context;
 }
 public BatchLogRepository(WasteContext context)
     : base(context)
 {
 }
Esempio n. 27
0
 public EFGoalRepository(WasteContext context) : base(context)
 {
 }
 public IdentityRepository(WasteContext context)
     : base(context)
 {
 }