public CheckPasswordInfo CheckPassword(string email, string password, string clientId, string remoteClient)
        {
            var t = _repo.GetByEmail(email);

            t.Wait();
            var customer = t.Result;

            if (customer != null)
            {
                var hash2 = PasswordUtils.CalcHash(password);
                if (customer.HashedPassword.SequenceEqual(hash2))
                {
                    _repo.InsertEvent(customer, "Login succeeded", clientId, remoteClient);
                    return(new CheckPasswordInfo {
                        Success = true, CustomerInfo = customer
                    });
                }
                _repo.InsertEvent(customer, "Login failed", clientId, remoteClient);
            }
            return(new CheckPasswordInfo {
                Success = false
            });
        }
        public async Task InitIfNeeded()
        {
            var t = await _collection.CountAsync(x => true);

            if (t == 0)
            {
                await _collection.InsertOneAsync(
                    new CustomerInfo { UserId = Guid.Parse("079290E8-1A30-4145-A576-263FE21193E6"), EMail = "*****@*****.**", HashedPassword = PasswordUtils.CalcHash("bob"), FirstName = "Bob", LastName = "Smith", DateOfBirth = new DateTime(1980, 06, 23), LoyaltyCardNumber = "888555444333" }
                    );

                await _collection.InsertOneAsync(
                    new CustomerInfo { UserId = Guid.Parse("A25D1FBC-860F-4AF2-9D89-1B65A43B00F4"), EMail = "*****@*****.**", HashedPassword = PasswordUtils.CalcHash("alice"), FirstName = "Alice", LastName = "Granger", DateOfBirth = new DateTime(1983, 03, 07), LoyaltyCardNumber = "888222111666" }
                    );
            }
        }