ui updates, use services
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
namespace BinaryDad.AacpsBusAlert.Services
|
||||
{
|
||||
public interface IUserService
|
||||
{
|
||||
ICollection<User> GetUsers();
|
||||
User GetUser(Guid id);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BinaryDad.AacpsBusAlert.Services
|
||||
{
|
||||
public class JsonUserService : IUserService
|
||||
{
|
||||
public ICollection<User> GetUsers()
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "users.json");
|
||||
|
||||
var usersJson = File.ReadAllText(path);
|
||||
|
||||
return JsonConvert.DeserializeObject<ICollection<User>>(usersJson);
|
||||
}
|
||||
|
||||
public User GetUser(Guid id)
|
||||
{
|
||||
return GetUsers().First(u => u.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user