Skip to content
Permalink
eb9ffc6ce5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
47 lines (41 sloc) 1.16 KB
using System.Collections.Generic;
using System.Threading.Tasks;
using SQLite;
using UEngage.Models;
namespace UEngage.Data
{
public class ReportDatabase
{
readonly SQLiteAsyncConnection _database;
public ReportDatabase(string dbPath)
{
_database = new SQLiteAsyncConnection(dbPath);
_database.CreateTableAsync<Report_>().Wait();
}
public Task<List<Report_>> GetReportsAsync()
{
return _database.Table<Report_>().ToListAsync();
}
public Task<Report_> GetReportAsync(int id)
{
return _database.Table<Report_>()
.Where(i => i.ID == id)
.FirstOrDefaultAsync();
}
public Task<int> SaveReportAsync(Report_ report)
{
if (report.ID != 0)
{
return _database.UpdateAsync(report);
}
else
{
return _database.InsertAsync(report);
}
}
public Task<int> DeleteReportAsync(Report report)
{
return _database.DeleteAsync(report);
}
}
}