AacpsBusAlert/BinaryDad.AacpsBusAlert.Services/UserService/JsonUserService.cs

22 lines
521 B
C#
Raw Normal View History

2022-10-05 02:23:14 +00:00
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);
}
}
}