-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartup.cs
More file actions
57 lines (50 loc) · 2 KB
/
Startup.cs
File metadata and controls
57 lines (50 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.Filters;
using Microsoft.Data.Entity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using TeamY.Infrastructure;
using TeamY.Services;
namespace TeamY
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
var connection = @"Data Source=DK-SQL2014;Initial Catalog=Hackathon.TeamY;User ID=teamy;Password=teamgalaxy;";
services.AddAuthorization();
services.AddMvc(config =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
config.Filters.Add(new AuthorizeFilter(policy));
});
services.AddSingleton<IUserService, UserService>();
services.AddScoped<IOctopusService, OctopusService>();
services.AddSingleton<ILocationDetailsService, LocationDetailsService>();
services.AddSingleton<IAppointmentService, AppointmentService>();
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<TeamyDbContext>(options => options.UseSqlServer(connection));
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
app.UseCookieAuthentication(options =>
{
options.AuthenticationScheme = "Cookie";
options.LoginPath = new PathString("/Account/Login/");
options.AccessDeniedPath = new PathString("/Account/Forbidden/");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
});
app.UseIISPlatformHandler();
app.UseDeveloperExceptionPage();
app.UseMvcWithDefaultRoute();
app.UseStaticFiles();
}
}
}