public async Task <IVerificationCode> AddCodeAsync(string email, string referer, string returnUrl, string cid, string traffic) { await DeleteCodesAsync(email); var entity = VerificationCodeEntity.Create(email, referer, returnUrl, cid, traffic); await _tablestorage.InsertOrReplaceAsync(entity); return(entity); }
public async Task DeleteCodesAsync(string email) { var existingCodes = await _tablestorage.GetDataAsync(VerificationCodeEntity.GeneratePartitionKey(), item => item.Email == email); foreach (var existingCode in existingCodes) { await _tablestorage.DeleteIfExistAsync(VerificationCodeEntity.GeneratePartitionKey(), VerificationCodeEntity.GenerateRowKey(existingCode.Key)); } }
public async Task <IVerificationCode> UpdateCodeAsync(string key) { var code = await _tablestorage.MergeAsync(VerificationCodeEntity.GeneratePartitionKey(), VerificationCodeEntity.GenerateRowKey(key), entity => { entity.Code = VerificationCodeEntity.GenerateCode(); entity.ResendCount++; return(entity); } ); return(code); }
public async Task <IVerificationCode> GetCodeAsync(string key) { return(await _tablestorage.GetDataAsync(VerificationCodeEntity.GeneratePartitionKey(), VerificationCodeEntity.GenerateRowKey(key))); }