fix
This commit is contained in:
+37
-7
@@ -43,8 +43,11 @@ using Services.Account;
|
||||
using Services.Item;
|
||||
using MyOffice.Services.Dashboard;
|
||||
using MyOffice.Services.Identity;
|
||||
using MyOffice.Services.Mapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
using MyOffice.Web.Infrastructure.Attributes;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
|
||||
//TODO: Data.Model only Repository and Service, response <-> mapper <-> web <-> mapper <-> service <-> repository
|
||||
//TODO: Project management
|
||||
@@ -73,7 +76,7 @@ using MyOffice.Services.Account.Domain;
|
||||
//TODO: report income
|
||||
//TODO: report outcome
|
||||
|
||||
public class Program
|
||||
public partial class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@@ -88,6 +91,8 @@ public class Program
|
||||
|
||||
private static void AddServices(WebApplicationBuilder builder)
|
||||
{
|
||||
#region Loging
|
||||
|
||||
builder.Services.AddLogging(logging =>
|
||||
logging.AddSimpleConsole(options =>
|
||||
{
|
||||
@@ -99,6 +104,8 @@ public class Program
|
||||
//File Logger
|
||||
builder.Logging.AddFile(builder.Configuration.GetSection("Logging"));
|
||||
|
||||
#endregion Loging
|
||||
|
||||
builder.Services.Configure<LoggerFilterOptions>(options =>
|
||||
{
|
||||
//options.AddFilter("IdentityServer4", LogLevel.Warning); // or LogLevel.None to completely disable
|
||||
@@ -108,7 +115,8 @@ public class Program
|
||||
// shared configuration
|
||||
builder.Configuration.AddConfiguration(SharedConfiguration.CreateConfigurationContainer());
|
||||
|
||||
// Database
|
||||
#region Database
|
||||
|
||||
var databaseProvider = builder.Configuration["DatabaseProvider"];
|
||||
if (databaseProvider == null)
|
||||
throw new NullReferenceException($"Configuration DatabaseProvider {databaseProvider}");
|
||||
@@ -120,6 +128,8 @@ public class Program
|
||||
var connectionConfiguration = new ConnectionConfiguration(databaseProvider, connectionString);
|
||||
RepositoryInitializer.Initialize(builder.Services, connectionConfiguration);
|
||||
|
||||
#endregion Database
|
||||
|
||||
// Configurations
|
||||
builder.Services.Configure<ExternalProvidersConfig>(
|
||||
builder.Configuration.GetSection("ExternalProviders")
|
||||
@@ -131,7 +141,7 @@ public class Program
|
||||
|
||||
builder.Services.AddScoped<IContextProvider, ContextProvider>();
|
||||
|
||||
AddMapping(builder);
|
||||
AddAutoMapper(builder);
|
||||
|
||||
AddRepositories(builder);
|
||||
|
||||
@@ -145,6 +155,8 @@ public class Program
|
||||
options.JsonSerializerOptions.MaxDepth = 0;
|
||||
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
||||
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
|
||||
});
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
@@ -152,6 +164,21 @@ public class Program
|
||||
//builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddCors();
|
||||
|
||||
builder.Services.AddControllersWithViews(options =>
|
||||
{
|
||||
options.Conventions.Add(new DefaultFromBodyBindingConvention());
|
||||
options.Filters.Add(typeof(GlobalModelStateValidatorAttribute));
|
||||
});
|
||||
|
||||
builder.Services.Configure<MvcOptions>(options =>
|
||||
{
|
||||
});
|
||||
|
||||
builder.Services.Configure<ApiBehaviorOptions>(x => {
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton<ProblemDetailsFactory, CustomProblemDetailsFactory>();
|
||||
}
|
||||
|
||||
private static void InitializeGlobalSettings(WebApplicationBuilder builder)
|
||||
@@ -245,7 +272,7 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddMapping(WebApplicationBuilder builder)
|
||||
private static void AddAutoMapper(WebApplicationBuilder builder)
|
||||
{
|
||||
builder.Services.AddAutoMapper(
|
||||
c =>
|
||||
@@ -253,7 +280,7 @@ public class Program
|
||||
c.AllowNullCollections = true;
|
||||
c.AllowNullDestinationValues = true;
|
||||
},
|
||||
typeof(AccountDto).Assembly,
|
||||
typeof(AccountDto).Assembly,
|
||||
typeof(AccountViewModel).Assembly
|
||||
);
|
||||
}
|
||||
@@ -272,7 +299,7 @@ public class Program
|
||||
builder.Services.AddScoped<IAccountAccessRepository, AccountAccessRepository>();
|
||||
builder.Services.AddScoped<IAccountAccessInviteRepository, AccountAccessInviteRepository>();
|
||||
builder.Services.AddScoped<IAccountAccountCategoryRepository, AccountAccountCategoryRepository>();
|
||||
|
||||
|
||||
builder.Services.AddScoped<IItemCategoryRepository, ItemCategoryRepository>();
|
||||
builder.Services.AddScoped<IItemRepository, ItemRepository>();
|
||||
builder.Services.AddScoped<IItemGlobalRepository, ItemGlobalRepository>();
|
||||
@@ -423,8 +450,11 @@ public class Program
|
||||
|
||||
app.UseIdentityServer();
|
||||
//app.UseAuthentication();
|
||||
//app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
|
||||
MapRoutes(app);
|
||||
|
||||
app.MapControllers();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user