1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-18 16:11:28 -05:00

Send APIs (#979)

* send work

* fix sql proj file

* update

* updates

* access id

* delete job

* fix delete job

* local send storage

* update sprocs for null checks
This commit is contained in:
Kyle Spearrin
2020-11-02 15:55:49 -05:00
committed by GitHub
parent a5db233e51
commit 82dd364e65
39 changed files with 1774 additions and 11 deletions

View File

@ -0,0 +1,13 @@
using System;
using Bit.Core.Models.Table;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Bit.Core.Repositories
{
public interface ISendRepository : IRepository<Send, Guid>
{
Task<ICollection<Send>> GetManyByUserIdAsync(Guid userId);
Task<ICollection<Send>> GetManyByDeletionDateAsync(DateTime deletionDateBefore);
}
}

View File

@ -0,0 +1,48 @@
using System;
using Bit.Core.Models.Table;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Dapper;
using System.Linq;
namespace Bit.Core.Repositories.SqlServer
{
public class SendRepository : Repository<Send, Guid>, ISendRepository
{
public SendRepository(GlobalSettings globalSettings)
: this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString)
{ }
public SendRepository(string connectionString, string readOnlyConnectionString)
: base(connectionString, readOnlyConnectionString)
{ }
public async Task<ICollection<Send>> GetManyByUserIdAsync(Guid userId)
{
using (var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<Send>(
$"[{Schema}].[Send_ReadByUserId]",
new { UserId = userId },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
public async Task<ICollection<Send>> GetManyByDeletionDateAsync(DateTime deletionDateBefore)
{
using (var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<Send>(
$"[{Schema}].[Send_ReadByDeletionDateBefore]",
new { DeletionDate = deletionDateBefore },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
}
}