﻿using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(PAaaS.Server.Startup))]

namespace PAaaS.Server
{
    using System.Data.Entity;
    using System.Web.Http;

    using PAaaS.Data;
    using PAaaS.Data.Migrations;

    using Ninject.Web.Common.OwinHost;
    using Ninject.Web.WebApi.OwinHost;
    using App_Start;
    using System.Reflection;
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<PAaaSDbContext, Configuration>());
            AutomapperConfig.RegisterMappings(Assembly.GetExecutingAssembly());

            this.ConfigureAuth(app);

            var config = new HttpConfiguration();
            WebApiConfig.Register(config);

            app.UseNinjectMiddleware(() => NinjectConfig.CreateKernel.Value);
            app.UseNinjectWebApi(config);
        }
    }
}
