Working full stack forums get
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
using BL.Interfaces;
|
||||
using DAL.Repositories;
|
||||
|
||||
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(WebApi.App_Start.NinjectWebCommon), "Start")]
|
||||
[assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(WebApi.App_Start.NinjectWebCommon), "Stop")]
|
||||
|
||||
@@ -10,6 +13,11 @@ namespace WebApi.App_Start
|
||||
|
||||
using Ninject;
|
||||
using Ninject.Web.Common;
|
||||
using System.Web.Http;
|
||||
using Ninject.Web.WebApi;
|
||||
using DAL;
|
||||
using DAL.Interfaces;
|
||||
using BL.Services;
|
||||
|
||||
public static class NinjectWebCommon
|
||||
{
|
||||
@@ -46,6 +54,10 @@ namespace WebApi.App_Start
|
||||
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
|
||||
|
||||
RegisterServices(kernel);
|
||||
|
||||
// Support WebAPI
|
||||
GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
|
||||
|
||||
return kernel;
|
||||
}
|
||||
catch
|
||||
@@ -61,6 +73,10 @@ namespace WebApi.App_Start
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
private static void RegisterServices(IKernel kernel)
|
||||
{
|
||||
}
|
||||
kernel.Bind<IFoorumDbContext>().To<FoorumDbContext>().InRequestScope();
|
||||
kernel.Bind<IFoorumRepository>().To<FoorumRepository>().InRequestScope();
|
||||
kernel.Bind<IPostRepository>().To<PostRepository>().InRequestScope();
|
||||
kernel.Bind<IFoorumService>().To<FoorumService>().InRequestScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace WebApi
|
||||
// Force always json response
|
||||
var jsonFormatter = new JsonMediaTypeFormatter();
|
||||
//optional: set serializer settings here
|
||||
config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));
|
||||
//config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user