-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
78 lines (62 loc) · 2.21 KB
/
Program.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using DocService.Models.Data.Identity;
using DocService.Repositories.Interfaces;
using DocService.Repositories.Repos;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using DocService.Utilities;
using DocService.Models.Data;
using DocService.Profiles;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSwaggerGen();
builder.Services.AddDbContext<IdentityAppDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("Database"));
});
//Identity Database Context
builder.Services.AddIdentity<IdentityUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = false)
.AddEntityFrameworkStores<IdentityAppDbContext>()
.AddDefaultTokenProviders();;
//Normal Database Context
builder.Services.AddDbContext<AppDbContext>(
options=>
options.UseSqlServer(builder.Configuration.GetConnectionString("Database")));
// Add services to the container.
builder.Services.AddControllersWithViews();
//Razor Runtime Compilation
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
builder.Services.AddRazorPages();
//Add Repository
builder.Services.AddScoped<IDoctorRepository, DoctorRepository>();
builder.Services.AddScoped<INurseRepository, NurseRepository>();
builder.Services.AddScoped<IPatientRepository, PatientRepository>();
builder.Services.AddScoped<IAppointmentRepository, AppointmentRepository>();
builder.Services.AddAutoMapper(typeof(MapPtofiles)); // The Righr way to do this
//AddMapper
//email
builder.Services.AddSingleton<IEmailSender,EmailSender>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/AccessDenied");
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
options.RoutePrefix = string.Empty;
});
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSwagger();
app.UseSwaggerUI();
app.UseRouting();
app.UseAuthentication();;
app.UseAuthorization();
app.MapRazorPages();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();