using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using ContactManager.Models;
using ContactManager.Services;

namespace ContactManager.Controllers
{
    public class ContactController : ApiController
    {
        private ContactRepository contactRep;

        public ContactController()
        {
            contactRep = new ContactRepository();
        }
        public Contact[] Get()
        {
            return contactRep.GetAllContacts();
        }

        public HttpResponseMessage Post(Contact contact)
        {
            this.contactRep.SaveContact(contact);

            var response = Request.CreateResponse<Contact>(System.Net.HttpStatusCode.Created, contact);

            return response;
        }
    }
}
