using DAL.New_Models;
using Microsoft.EntityFrameworkCore;

namespace UseSQLQueryData
{
    public class Program
    {
        public static DateTime Dt = DateTime.Now;
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.

            Dt =new DateTime(1970,1,1,0,0,0);
            builder.Services.AddDbContext<RicsContext>(options =>
            {
                options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
            });
            builder.Services.AddControllers();

            builder.Services.AddMemoryCache();
            builder.Services.AddCors(options =>
            {
                options.AddPolicy(name: "KuaYu",
                                  policy =>
                                  {
                                      policy
                                       .AllowAnyOrigin()
                                       .AllowAnyHeader()
                                       .AllowAnyMethod();
                                  });
            });
            builder.Services.AddOutputCache();
            var app = builder.Build();

            // Configure the HTTP request pipeline.

            app.UseCors("KuaYu");
            app.UseAuthorization();


            app.MapControllers();

            app.Run();
        }
    }
}
