1+ using Asp . Versioning ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Scalar . AspNetCore ;
4+ using simple_dapper . application . Services . Implementations ;
5+ using simple_dapper . application . Services . Interfaces ;
6+ using simple_dapper . domain . Interfaces ;
7+ using simple_dapper . infrastructure . dapper . Repositories ;
8+ using simple_dapper . infrastructure . Persistence ;
9+
10+ var builder = WebApplication . CreateBuilder ( args ) ;
11+
12+ #region Services
13+
14+ builder . Services . AddControllers ( ) ;
15+ builder . Services . AddOpenApi ( ) ;
16+
17+
18+ builder . Services . AddApiVersioning ( options=>
19+ {
20+ options . AssumeDefaultVersionWhenUnspecified = true ;
21+ options . DefaultApiVersion = new ApiVersion ( 1 , 0 ) ;
22+ options . ReportApiVersions = true ;
23+ } ) ;
24+
25+ #region DI
26+
27+ // repos
28+ builder . Services . AddScoped < INoteRepository , DapperNoteRepository > ( ) ;
29+
30+ //services
31+ builder . Services . AddScoped < INoteService , NoteService > ( ) ;
32+
33+ #endregion
34+
35+ builder . Services . AddDbContext < ApplicationContext > ( option=>
36+ {
37+ option . UseSqlServer ( builder . Configuration . GetConnectionString ( "Default" ) ) ;
38+ } ) ;
39+
40+ #endregion
41+
42+ var app = builder . Build ( ) ;
43+
44+ #region Middlewares
45+
46+ app . UseHttpsRedirection ( ) ;
47+ app . MapControllers ( ) ;
48+
49+ if ( app . Environment . IsDevelopment ( ) )
50+ {
51+ app . MapOpenApi ( ) ;
52+
53+ app . MapScalarApiReference ( options=>
54+ {
55+ options . WithDefaultHttpClient ( ScalarTarget . CSharp , ScalarClient . RestSharp ) ;
56+
57+
58+ //.WithTheme(ScalarTheme.Purple)
59+ //.WithTitle("alipour")
60+ //.WithApiKeyAuthentication(keyOptions => keyOptions.Token = "apiToken");
61+ //.WithPreferredScheme("ApiKey");
62+ } ) ;
63+ }
64+
65+ app . Run ( ) ;
66+
67+ #endregion