Skip to content
Permalink
512a8429ba
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
69 lines (54 sloc) 1.5 KB
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using App3.Models;
using App3.Services;
using SQLite;
using Xamarin.Essentials;
namespace App3.Services
{
public class DataService : IDataService
{
SQLiteAsyncConnection db;
async Task Init()
{
if (db != null)
return;
var databasePath = Path.Combine(FileSystem.AppDataDirectory, "MyData.db");
db = new SQLiteAsyncConnection(databasePath);
await db.CreateTableAsync<User>();
}
public async Task AddUser(string Username, string Password)
{
await Init();
var User = new User
{
UserName = Username,
Password = Password,
};
var id = await db.InsertAsync(User);
}
public async Task RemoveUser(int id)
{
await Init();
await db.DeleteAsync<User>(id);
}
public async Task<IEnumerable<User>> GetUser()
{
await Init();
var User = await db.Table<User>().ToListAsync();
return User;
}
public Task AddUser(object username, object password)
{
throw new NotImplementedException();
}
public Task AddUser(string username, object password)
{
throw new NotImplementedException();
}
}
}