-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
75 lines (52 loc) · 2.05 KB
/
Program.cs
File metadata and controls
75 lines (52 loc) · 2.05 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
using HospitalApp.Infrastructure;
using HospitalApp.Models;
using HospitalApp.Models.Entities;
using HospitalApp.Services;
using HospitalApp.Services.Interfaces;
using Serilog;
using Serilog.Events;
namespace HospitalApp;
public class Program
{
public static void Main(string[] args)
{
var app = CreateWebApplication(args);
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors();
app.UseHttpsRedirection();
app.MapControllers();
app.Run();
}
private static WebApplication CreateWebApplication(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Override("Microsoft", LogEventLevel.Error)
.WriteTo.Console()
.WriteTo.File(
path: "HospitalApp-.log",
rollingInterval: RollingInterval.Day,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
.CreateLogger();
builder.Logging.ClearProviders();
builder.Host.UseSerilog(Log.Logger, true);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddCors();
builder.Services.AddMemoryCache();
builder.Services.AddAutoMapper(typeof(HospitalAppMappingProfile));
builder.Services.AddDbContext<HospitalAppContext>();
builder.Services.AddTransient<IListEntityService<Doctor>, ListEntityService<Doctor>>();
builder.Services.AddTransient<IDoctorService, DoctorService>();
builder.Services.AddTransient<IListEntityService<Patient>, ListEntityService<Patient>>();
builder.Services.AddTransient<IPatientService, PatientService>();
builder.Services.AddTransient<INsiService, NsiService>();
return builder.Build();
}
}