using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Net.Http.Headers;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

using TFC.Context;

namespace TFC
{
    // Nota: para obtener instrucciones sobre cómo habilitar el modo clásico de IIS6 o IIS7, 
    // visite http://go.microsoft.com/?LinkId=9394801

    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");
            Database.SetInitializer(new DataContextInitializer());
            //JsonSerializerSettings serializerSettings = new JsonSerializerSettings();

            //serializerSettings.Converters.Add(new IsoDateTimeConverter());

            //var jsonFormatter = new JsonNetFormatter(serializerSettings);
            
            //jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

            //GlobalConfiguration.Configuration.Formatters.Insert(0, jsonFormatter);
        }
    }
}