using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using DALWebApi.Interfaces;
using Domain.Contacts;

namespace DALWebApi.Repositories
{
    public class PersonRepository : WebApiRepository<Person>, IPersonRepository
    {
        public PersonRepository(string baseUrl) : base(baseUrl)
        {
        }

        public ICollection<Person> AllForUser(string userId)
        {
            var response = WebClient.GetAsync("AllForUser/"+userId).Result;
            if (response.IsSuccessStatusCode)
            {
                var res = response.Content.ReadAsAsync<List<Person>>().Result;
                return res;
            }

            return new List<Person>();
            //return DbSet.Where(a => a.UserId == userId).ToList();
        }
    }
}
