Wonky.Client/Wonky.Client/Program.cs
Frede Hundewadt 2b65bfe8d2 adding product catalog without price for b2b product lookup
refactor namespace to distinguish better product catalog from price catalog
2023-10-29 04:29:27 +01:00

116 lines
5.8 KiB
C#

// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Net.Http.Headers;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Options;
using Toolbelt.Blazor.Extensions.DependencyInjection;
using Blazored.LocalStorage;
using Blazored.Toast;
using Wonky.Client;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Local.Services;
using Wonky.Client.Shared;
using Wonky.Entity.Configuration;
using Wonky.Entity.DTO;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
builder.Services.AddScoped(sp =>
sp.GetService<IHttpClientFactory>().CreateClient("inno-api"));
builder.Services.AddHttpClient("inno-api", (sp, cl) =>
{
var apiConfig = sp.GetRequiredService<IOptions<ApiConfig>>();
cl.BaseAddress = new Uri(apiConfig.Value.BaseUrl);
cl.DefaultRequestHeaders.CacheControl = CacheControlHeaderValue.Parse("no-cache, no-store, must-revalidate");
cl.DefaultRequestHeaders.Add("Pragma", "no-cache");
cl.EnableIntercept(sp);
});
builder.Services.AddBlazoredToast();
builder.Services.AddHttpClientInterceptor();
// api config object
builder.Services.Configure<ApiConfig>(builder.Configuration.GetSection("ApiConfig"));
// app info object
builder.Services.Configure<AppInfo>(builder.Configuration.GetSection("AppInfo"));
// interface
builder.Services.AddScoped<IClipboardService, ClipboardService>();
// user
builder.Services.AddScoped<IUserInfoService, UserInfoService>();
builder.Services.AddScoped<UserPreferenceService, UserPreferenceService>();
// crm repositories
builder.Services.AddScoped<IAdvisorActivityRepository, AdvisorActivityRepository>();
builder.Services.AddScoped<IAdvisorCustomerRepository, AdvisorCustomerRepository>();
builder.Services.AddScoped<IAdvisorContactRepository, AdvisorContactRepository>();
builder.Services.AddScoped<IAdvisorCustomerHistoryRepository, AdvisorCustomerHistoryRepository>();
builder.Services.AddScoped<IAdvisorTaskItemRepository, AdvisorTaskItemRepository>();
builder.Services.AddScoped<IAdvisorSalesReportRepository, AdvisorSalesReportRepository>();
builder.Services.AddScoped<IAdvisorWorkplaceRepository, AdvisorWorkplaceRepository>();
builder.Services.AddScoped<IExternalProductRepository, ExternalProductRepository>();
// administrative repositories
builder.Services.AddScoped<ICountryCustomerHistoryRepository, CountryCustomerHistoryRepository>();
builder.Services.AddScoped<ICountryCustomerActivityRepository, CountryCustomerActivityRepository>();
builder.Services.AddScoped<ICountryProductCatalogRepository, CountryProductCatalogRepository>();
builder.Services.AddScoped<ICountryPriceCatalogRepository, CountryPriceCatalogRepository>();
builder.Services.AddScoped<ICountryCustomerRepository, CountryCustomerRepository>();
builder.Services.AddScoped<ICountryReportRepository, CountryReportRepository>();
builder.Services.AddScoped<ISystemLabelsRepository, SystemLabelsRepository>();
builder.Services.AddScoped<ISystemTextsRepository, SystemTextsRepository>();
builder.Services.AddScoped<ISystemUserRepository, SystemUserRepository>();
builder.Services.AddScoped<ICountryUserInfoRepository, CountryUserInfoRepository>();
builder.Services.AddScoped<ISupportDocumentRepository, SupportDocumentRepository>();
builder.Services.AddScoped<ISupportManagementRepository, SupportManagementRepository>();
builder.Services.AddScoped<ICountryActivityRepository, CountryActivityRepository>();
builder.Services.AddScoped<IOfficeOrderListRepository, OfficeOrderListRepository>();
// warehouse repository
builder.Services.AddScoped<IOrderProcessRepository, OrderProcessRepository>();
// mail service
builder.Services.AddScoped<ISystemSendMailService, SystemSendMailService>();
builder.Services.AddScoped<ISystemSendSmsService, SystemSendSmsService>();
// interceptor
builder.Services.AddScoped<HttpInterceptorService>();
// authorization
builder.Services.AddAuthorizationCore();
// authentication state provider
builder.Services.AddScoped<AuthenticationStateProvider, AuthStateProvider>();
// authentication service
builder.Services.AddScoped<IAuthenticationService, AuthenticationService>();
// refresh token service
builder.Services.AddScoped<RefreshTokenService>();
// vat registry service
builder.Services.AddScoped<VatInfoLookupService>();
// activity draft service
builder.Services.AddScoped<OrderDraftService>();
// cabinet service
builder.Services.AddScoped<ICabinetDrawerService, CabinetDrawerService>();
// storage
builder.Services.AddBlazoredLocalStorage();
// Swedisd Personal Company OrgNo Search
builder.Services.AddScoped<ISwedishPersonalOrgService, SwedishPersonalOrgService>();
// b2b service
builder.Services.AddScoped<IB2BRepository, B2BRepository>();
// ---------------------------------------
await builder.Build().RunAsync();