Exemplo n.º 1
0
        public void Add(User entity)
        {
            if (_db.Users.Any(u => u.Username.Equals(entity.Username, StringComparison.OrdinalIgnoreCase)))
            {
                throw new ArgumentNullException(nameof(entity), "Username was already taken!");
            }

            _db.Users.Add(entity);
            _db.SaveChanges();
        }
Exemplo n.º 2
0
 public void Add(DbConnection entity)
 {
     _db.DbConnections.Add(entity);
     _db.Entry(entity.User).State = EntityState.Detached;
     _db.SaveChanges();
 }