Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
179 lines (162 loc) · 8 KB
/
Copy pathProgram.cs
File metadata and controls
179 lines (162 loc) · 8 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using Microsoft.AspNetCore.Authentication.Cookies;
using Scalar.AspNetCore; // <-- Scalar UI -->
using VEMS.Areas.AdminPortal;
using VEMS.Areas.AdminPortal.Services;
using VEMS.Areas.AdminPortal.Services.Admissions;
using VEMS.Areas.AdminPortal.Services.Examination;
using VEMS.Areas.AdminPortal.Services.Fee;
using VEMS.Areas.StudentPortal.Services;
using VEMS.Areas.TeacherPortal;
using VEMS.Areas.TeacherPortal.Services;
using VEMS.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var mvcBuilder = builder.Services.AddControllersWithViews();
if (builder.Environment.IsDevelopment())
{
mvcBuilder.AddRazorRuntimeCompilation();
}
builder.Services.AddDistributedMemoryCache();
builder.Services.AddSession(options =>
{
options.Cookie.Name = "VEMS.AdminPortal.Session";
options.IdleTimeout = TimeSpan.FromHours(8);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
builder.Services
.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.Cookie.Name = "VEMS.StudentPortal.Auth";
options.LoginPath = "/studentportal/login";
options.AccessDeniedPath = "/studentportal/login";
options.ExpireTimeSpan = TimeSpan.FromHours(8);
options.SlidingExpiration = true;
})
.AddCookie(TeacherPortalAuth.Scheme, options =>
{
options.Cookie.Name = TeacherPortalAuth.CookieName;
options.LoginPath = "/teacherportal/login";
options.AccessDeniedPath = "/teacherportal/login";
options.ExpireTimeSpan = TimeSpan.FromHours(8);
options.SlidingExpiration = true;
})
.AddCookie(AdminPortalAuth.Scheme, options =>
{
options.Cookie.Name = AdminPortalAuth.CookieName;
options.LoginPath = "/adminportal/login";
options.AccessDeniedPath = "/adminportal/login";
options.ExpireTimeSpan = TimeSpan.FromHours(8);
options.SlidingExpiration = true;
});
builder.Services.AddScoped<IStudentLoginRepository, StudentLoginRepository>();
builder.Services.AddScoped<ITeacherLoginRepository, TeacherLoginRepository>();
builder.Services.AddScoped<ITeacherAccountRepository, TeacherAccountRepository>();
builder.Services.AddScoped<ITeacherAcademicRepository, TeacherAcademicRepository>();
builder.Services.AddScoped<IClassRepository, ClassRepository>();
builder.Services.AddScoped<IStudentProfileRepository, StudentProfileRepository>();
builder.Services.AddScoped<IStudentChallanRepository, StudentChallanRepository>();
builder.Services.AddScoped<IStudentCourseRepository, StudentCourseRepository>();
builder.Services.AddScoped<IEmployeeRepository, EmployeeRepository>();
builder.Services.AddScoped<ITeacherRepository, TeacherRepository>();
builder.Services.AddScoped<ITeacherCourseAssignmentRepository, TeacherCourseAssignmentRepository>();
builder.Services.AddScoped<ITimetableRepository, TimetableRepository>();
builder.Services.AddScoped<ITeacherClassCourseRepository, TeacherClassCourseRepository>();
builder.Services.AddScoped<IEmployeeLoginRepository, EmployeeLoginRepository>();
builder.Services.AddScoped<IStudentRepository, StudentRepository>();
builder.Services.AddScoped<ICourseRepository, CourseRepository>();
builder.Services.AddScoped<IProgramEnrollmentRepository, ProgramEnrollmentRepository>();
builder.Services.AddScoped<IClassCourseRepository, ClassCourseRepository>();
builder.Services.AddScoped<IStudentCourseEnrollmentRepository, StudentCourseEnrollmentRepository>();
builder.Services.AddScoped<IProgramRepository, ProgramRepository>();
builder.Services.AddScoped<IStudentsLoginRepository, StudentsLoginRepository>();
builder.Services.AddScoped<IConfigurationsRepository, ConfigurationsRepository>();
builder.Services.AddScoped<IAcademicYearRepository, AcademicYearRepository>();
builder.Services.AddScoped<ISectionRepository, SectionRepository>();
builder.Services.AddScoped<IClassSectionRepository, ClassSectionRepository>();
builder.Services.AddScoped<ICourseSectionRepository, CourseSectionRepository>();
builder.Services.AddScoped<IStudentCourseRegistrationRepository, StudentCourseRegistrationRepository>();
builder.Services.AddScoped<IPeriodRepository, PeriodRepository>();
builder.Services.AddScoped<ITimetablesRepository, TimetablesRepository>();
builder.Services.AddScoped<IProgramCourseRepository, ProgramCourseRepository>();
builder.Services.AddScoped<ITeacherCourseLinkRepository, TeacherCourseLinkRepository>();
builder.Services.AddScoped<ITeacherAssignmentRepository, TeacherAssignmentRepository>();
builder.Services.AddScoped<IStudentEnrollmentLinkRepository, StudentEnrollmentLinkRepository>();
builder.Services.AddScoped<IFeeLookupRepository, FeeLookupRepository>();
builder.Services.AddScoped<IFeeHeadRepository, FeeHeadRepository>();
builder.Services.AddScoped<IFeeStructureRepository, FeeStructureRepository>();
builder.Services.AddScoped<IFeeConcessionRepository, FeeConcessionRepository>();
builder.Services.AddScoped<IFeeChallanRepository, FeeChallanRepository>();
builder.Services.AddScoped<IFeePaymentRepository, FeePaymentRepository>();
builder.Services.AddScoped<IExaminationBrowseRepository, ExaminationBrowseRepository>();
builder.Services.AddScoped<IStudentApplicationAdminRepository, StudentApplicationAdminRepository>();
builder.Services.AddScoped<IConfigurationValuesProvider, ConfigurationValuesProvider>();
builder.Services.AddScoped<IStudentApplicationRepository, StudentApplicationRepository>();
builder.Services.AddScoped<IStudentApplicationPageFactory, StudentApplicationPageFactory>();
// <-- Scalar / OpenAPI: AddControllersWithViews above already registers controllers + API explorer. -->
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// NOT DEVELOPMENT: Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
// DEVELOPMENT: Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
// <-- Scalar UI -->
// 1. Generate the Swagger JSON file
app.UseSwagger(options =>
{
options.RouteTemplate = "openapi/{documentName}.json";
});
// 2. Map the Scalar UI endpoint
app.MapScalarApiReference(options =>
{
options.Authentication = new ScalarAuthenticationOptions
{
// Use the plural property with a new list
PreferredSecuritySchemes = new List<string> { "Cookie" }
};
// This allows Scalar to send your "VEMS.StudentPortal.Auth" cookie
// when you click "Test Request"
});
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseSession();
app.UseAuthentication();
app.UseAuthorization();
// Portal area routes. Keep these before the default public route.
app.MapAreaControllerRoute(
name: "student-portal",
areaName: "StudentPortal",
pattern: "studentportal/{controller=Dashboard}/{action=Index}/{id?}");
app.MapAreaControllerRoute(
name: "teacher-portal",
areaName: "TeacherPortal",
pattern: "teacherportal/{controller=Dashboard}/{action=Index}/{id?}");
app.MapAreaControllerRoute(
name: "admin-portal",
areaName: "AdminPortal",
pattern: "adminportal/{controller=Dashboard}/{action=Index}/{id?}");
// Preserve the previously added management portal route so existing links keep working.
app.MapAreaControllerRoute(
name: "management-portal",
areaName: "ManagementPortal",
pattern: "ManagementPortal/{controller=Home}/{action=Index}/{id?}");
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapControllers(); // <-- Scalar UI -->
app.Run();