// public async Task<IEnumerable<User>> GetUsers() // { // var users = await _context.Users.Include(x => x.Posts).ToListAsync(); // return users; // } public async Task <Post> AddPost(Post post) { var response = await _context.AddAsync(post); await _context.SaveChangesAsync(); return(post); }
public async Task <Actividad> Register(Actividad actividad) { // Agregar el objeto al contexto await _context.AddAsync(actividad); // Realizar el guardado en nuestro repositorio(Base de Datos) await _context.SaveChangesAsync(); return(actividad); }
public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); // user.PasswordHash=passwordHash; // user.PasswordSalt=passwordSalt; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(user); }
public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; CreatePassWordHash(password, out passwordHash, out passwordSalt); //out is making reference type so that if the passwordHash and passowrdSat Changes in the function they will automatically will change user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(user); }
public async Task <User> Register(User user, string password) { //throw new System.NotImplementedException(); byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(user); }
public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; // out this passing by reference CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _dbcontext.AddAsync(user); await _dbcontext.SaveChangesAsync(); return(user); }
public async Task <User> Register(User user, string password) { byte[] PasswordHash, PasswordSalt; ComputePasswordHash(password, out PasswordHash, out PasswordSalt); user.PasswordSalt = PasswordSalt; user.PasswordHash = PasswordHash; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(user); }
public async Task <User> register(User user, string password) //psw = diellor (si input) { byte[] passwordHash; byte[] passwordSalt; //the method creates/populates these bytearr createPasswordHash(password, out passwordHash, out passwordSalt); //we want to pass by reference so we use out user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await context.AddAsync(user); await context.SaveChangesAsync(); return(user); }
public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; // Crear el password hash CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; //Agregar el objeto al contexto await _context.AddAsync(user); //REalizar el guardado en la BBDD await _context.SaveChangesAsync(); return(user); }
/// Register new user in database and protect password with cryptography public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; // 'out' before passwordHash makes it we passing a referance to this variables // and when we change it inside this methed automaticly update value of variable CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(user); }
public async Task <User> Register(User user, string password) { byte[] passwordHash, passwordSalt; // out: atributos são passados como referência e não como valor. // Quando os valores desses atributos forem atualizados, as variáveis // byte[] passwordHash, passwordSalt, irão receber esses valores. CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _dataContext.AddAsync(user); await _dataContext.SaveChangesAsync(); return(user); }
public async Task <User> Register(User newUser, string password) { byte[] passwordHash, passwordSalt; /* * - use keyword `out` to pass references as inputs instead of * passing values of unassigned local variables */ CreatePassWordHash(password, out passwordHash, out passwordSalt); newUser.PasswordHash = passwordHash; newUser.PasswordSalt = passwordSalt; await _context.AddAsync(newUser); await _context.SaveChangesAsync(); return(newUser); }
public async Task <User> Register(User user, string password) { try { byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; await _context.AddAsync(user); await _context.SaveChangesAsync(); return(user); } catch (Exception ex) { return(null); } }
public async Task Add <T>(T entity) where T : class { await _context.AddAsync(entity); }