Пример #1
0
        public async Task <bool> Authenticate(LoginViewModel model)
        {
            using (var connection = _factory.CreateConnection())
            {
                string query = "SELECT *FROM Users where login=@login";

                var u = await connection.QueryFirstOrDefaultAsync <User>(query, new { login = model.Login });

                if (u == null || !BC.Verify(model.Password, u.PasswordHash))
                {
                    return(false);
                }

                return(true);
            }
        }
Пример #2
0
 public virtual async Task CreateAsync(T entity)
 {
     using (var connection = _factory.CreateConnection())
     {
         entity.Id = await connection.InsertAsync(entity);
     }
 }