Created
September 26, 2016 09:12
-
-
Save AndyButland/ff1c12e21a66236af0e66fe62861ef99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using AutoMapper; | |
using MediatR; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
var connection = @"Server=.\SQLEXPRESS2012;Database=AspNetCoreToDo;Trusted_Connection=True;"; | |
services.AddDbContext<ToDoContext>(options => | |
options.UseSqlServer(connection)); | |
services.AddSession(); | |
services.AddMvc(); | |
services.AddAutoMapper(GetExecutingAssembly()); | |
services.AddMediatR(GetExecutingAssembly()); | |
} | |
public void Configure(IApplicationBuilder app, | |
IHostingEnvironment env, | |
ILoggerFactory loggerFactory) | |
{ | |
loggerFactory.AddConsole(); | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.UseStaticFiles(); | |
app.UseSession(); | |
app.UseMvc(routes => | |
{ | |
routes.MapRoute( | |
name: "default", | |
template: "{controller=Home}/{action=Index}/{id?}"); | |
}); | |
} | |
private static Assembly GetExecutingAssembly() | |
{ | |
return typeof(Startup).GetTypeInfo().Assembly; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment