﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Bokninssystem.Models;

namespace Bokninssystem.Helpers
{
    public class Connect
    {
        private HttpClient HttpClient()
        {
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", CredentialHelper.Credential);
            client.BaseAddress = new Uri("http://localhost:64611/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            return client;
        }


        public async Task<bool> Post(string adress, object obj)
        {
            var client = HttpClient();
            var respone = await client.PostAsJsonAsync(adress, obj);
            if(respone.IsSuccessStatusCode)            
                return true;            
            return false;
            
        }
        public void Get(string adress)
        {

        }
        public void Put()
        {

        }
        public void Delete()
        {
            
        }
        
        
    }
}