예제 #1
0
        public async Task <IClientAccount> GetByIdAsync(string id)
        {
            var partitionKey = ClientAccountEntity.GeneratePartitionKey();
            var rowKey       = ClientAccountEntity.GenerateRowKey(id);

            return(await _clientsTablestorage.GetDataAsync(partitionKey, rowKey));
        }
예제 #2
0
        public Task ChangePhoneAsync(string clientId, string phoneNumber)
        {
            var partitionKey = ClientAccountEntity.GeneratePartitionKey();
            var rowKey       = ClientAccountEntity.GenerateRowKey(clientId);

            return(_clientsTablestorage.ReplaceAsync(partitionKey, rowKey, itm =>
            {
                itm.Phone = phoneNumber;
                return itm;
            }));
        }
예제 #3
0
        public async Task <IClientAccount> RegisterAsync(IClientAccount clientAccount, string password)
        {
            var newEntity   = ClientAccountEntity.CreateNew(clientAccount, password);
            var indexEntity = AzureIndex.Create(IndexEmail, newEntity.Email, newEntity);

            await _emailIndices.InsertAsync(indexEntity);

            await _clientsTablestorage.InsertAsync(newEntity);

            return(newEntity);
        }
예제 #4
0
        public Task ChangePassword(string clientId, string newPassword)
        {
            var partitionKey = ClientAccountEntity.GeneratePartitionKey();
            var rowKey       = ClientAccountEntity.GenerateRowKey(clientId);

            return(_clientsTablestorage.ReplaceAsync(partitionKey, rowKey, itm =>
            {
                itm.SetPassword(newPassword);
                return itm;
            }));
        }
예제 #5
0
        public async Task <string> GenerateNotificationsId(string clientId)
        {
            var partitionKey = ClientAccountEntity.GeneratePartitionKey();
            var rowKey       = ClientAccountEntity.GenerateRowKey(clientId);

            var updated = await _clientsTablestorage.ReplaceAsync(partitionKey, rowKey, itm =>
            {
                itm.NotificationsId = Guid.NewGuid().ToString("N");
                return(itm);
            });

            return(updated.NotificationsId);
        }
예제 #6
0
        public static ClientAccountEntity CreateNew(IClientAccount clientAccount, string password)
        {
            var result = new ClientAccountEntity
            {
                PartitionKey    = GeneratePartitionKey(),
                RowKey          = Guid.NewGuid().ToString(),
                NotificationsId = Guid.NewGuid().ToString("N"),
                Email           = clientAccount.Email.ToLower(),
                Phone           = clientAccount.Phone,
                Registered      = clientAccount.Registered
            };

            result.SetPassword(password);

            return(result);
        }
예제 #7
0
        public async Task <bool> IsPasswordCorrect(string clientId, string password)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                return(false);
            }

            var entity = await _clientsTablestorage.GetDataAsync(ClientAccountEntity.GeneratePartitionKey(), ClientAccountEntity.GenerateRowKey(clientId));

            if (entity != null)
            {
                return(entity.CheckPassword(password));
            }

            return(false);
        }
예제 #8
0
        public async Task <IEnumerable <IClientAccount> > GetByIdAsync(string[] ids)
        {
            var partitionKey = ClientAccountEntity.GeneratePartitionKey();

            return(await _clientsTablestorage.GetDataAsync(partitionKey, ids));
        }