1
0
mirror of https://github.com/bitwarden/server synced 2026-01-06 02:23:51 +00:00

cipher details create/update

This commit is contained in:
Kyle Spearrin
2017-03-18 23:41:46 -04:00
parent 3d5437e238
commit 26b553c248
16 changed files with 159 additions and 44 deletions

View File

@@ -85,6 +85,41 @@ namespace Bit.Core.Repositories.SqlServer
}
}
public async Task CreateAsync(CipherDetails cipher)
{
cipher.SetNewId();
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.ExecuteAsync(
$"[{Schema}].[CipherDetails_Create]",
cipher,
commandType: CommandType.StoredProcedure);
}
}
public async Task ReplaceAsync(CipherDetails obj)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.ExecuteAsync(
$"[{Schema}].[CipherDetails_Update]",
obj,
commandType: CommandType.StoredProcedure);
}
}
public async Task UpsertAsync(CipherDetails cipher)
{
if(cipher.Id.Equals(default(Guid)))
{
await CreateAsync(cipher);
}
else
{
await ReplaceAsync(cipher);
}
}
public Task UpdateUserEmailPasswordAndCiphersAsync(User user, IEnumerable<Cipher> ciphers)
{
if(ciphers.Count() == 0)