using System.Threading.Tasks; using Bit.App.Abstractions; using Bit.App.Models.Data; using System.Collections.Generic; using System.Linq; namespace Bit.App.Repositories { public class CipherCollectionRepository : BaseRepository, ICipherCollectionRepository { public CipherCollectionRepository(ISqlService sqlService) : base(sqlService) { } public Task> GetAllByUserIdAsync(string userId) { var cipherCollections = Connection.Table().Where(f => f.UserId == userId) .Cast(); return Task.FromResult(cipherCollections); } public Task> GetAllByUserIdCollectionAsync(string userId, string collectionId) { var cipherCollections = Connection.Table().Where( f => f.UserId == userId && f.CollectionId == collectionId).Cast(); return Task.FromResult(cipherCollections); } public virtual Task InsertAsync(CipherCollectionData obj) { Connection.Insert(obj); return Task.FromResult(0); } public virtual Task DeleteAsync(CipherCollectionData obj) { Connection.Delete(obj.Id); return Task.FromResult(0); } public virtual Task DeleteByUserIdAsync(string userId) { Connection.Execute("DELETE FROM CipherCollection WHERE UserId = ?", userId); return Task.FromResult(0); } } }