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 ContactRepository : WebApiRepository<Contact>, IContactRepository
    {
        public ContactRepository(string baseUrl) : base(baseUrl)
        {
        }

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

            return new List<Contact>();

            //return DbSet.
            //    Where(a => a.Person.UserId == userId).
            //    Include(b => b.ContactType).
            //    Include(c => c.Person).
            //    ToList();
            throw new NotImplementedException();
        }
    }
}
