1
0
mirror of https://github.com/bitwarden/mobile synced 2026-02-25 00:52:49 +00:00

Added icons for iOS. Broke out data access into repositories. Added syncing service.

This commit is contained in:
Kyle Spearrin
2016-05-06 00:17:38 -04:00
parent 24a5a16723
commit decd3fc24e
46 changed files with 773 additions and 150 deletions

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bit.App.Abstractions;
using SQLite;
namespace Bit.App.Repositories
{
public abstract class Repository<T, TId> : IRepository<T, TId>
where TId : IEquatable<TId>
where T : class, IDataObject<TId>, new()
{
public Repository(ISqlService sqlService)
{
Connection = sqlService.GetConnection();
}
protected SQLiteConnection Connection { get; private set; }
public virtual Task<T> GetByIdAsync(TId id)
{
return Task.FromResult(Connection.Get<T>(id));
}
public virtual Task<IEnumerable<T>> GetAllAsync()
{
return Task.FromResult(Connection.Table<T>().Cast<T>());
}
public virtual Task InsertAsync(T obj)
{
Connection.Insert(obj);
return Task.FromResult(0);
}
public virtual Task UpdateAsync(T obj)
{
Connection.Update(obj);
return Task.FromResult(0);
}
public virtual async Task DeleteAsync(T obj)
{
await DeleteAsync(obj.Id);
}
public virtual Task DeleteAsync(TId id)
{
Connection.Delete<T>(id);
return Task.FromResult(0);
}
}
}