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);
        }
    }
}
