This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
webBuilder.UseStartup<Startup>(); | |
}) | |
.ConfigureAppConfiguration((context, config) => | |
{ | |
if (context.HostingEnvironment.IsProduction()) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Log<TState>( | |
Microsoft.Extensions.Logging.LogLevel logLevel, | |
EventId eventId, | |
TState state, | |
Exception exception, | |
Func<TState, Exception, string> formatter) | |
{ | |
if (!IsEnabled(logLevel)) | |
{ | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
autoReload="true" | |
internalLogLevel="Info" | |
internalLogFile="${basedir}Logsinternal-nlog.txt"> | |
<!-- enable asp.net core layout renderers --> | |
<extensions> | |
<add assembly="NLog.Web.AspNetCore" /> | |
<add assembly="Microsoft.ApplicationInsights.NLogTarget" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NLogger : Microsoft.Extensions.Logging.ILogger | |
{ | |
private readonly Logger logger; | |
private readonly string name; | |
private readonly NloggerConfiguration nloggerConfiguration; | |
private readonly UserContext userContext; | |
private readonly RequestContext requestContext; | |
public NLogger(string name, | |
NloggerConfiguration nloggerConfiguration, | |
UserContext userContext, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure( | |
IApplicationBuilder app, | |
IWebHostEnvironment env, | |
IApiVersionDescriptionProvider provider, | |
ILoggerFactory loggerFactory, | |
UserContext userContext, | |
RequestContext requestContext) | |
{ | |
loggerFactory.AddProvider( | |
new LoggerProvider(new NloggerConfiguration(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Logging": { | |
"LogLevel": { | |
"Default": "Trace", | |
"Microsoft.AspNetCore.Hosting.Diagnostics": "Information", | |
"Microsoft.AspNetCore.Authentication": "Information", | |
"Microsoft.*": "Error", | |
"System.*": "Error" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2021-06-22 13:41:32.5948|INFO|Request finished HTTP/1.1 GET https://azure-api.azurewebsites.net/v1/healthcheck - - - 200 - - 0.6111ms |Microsoft.AspNetCore.Hosting.Diagnostics|UserId: |Channel: Unknown|Environment: Production|UserAgent: Azure Traffic Manager Endpoint Monitor|CorrelationId: CorrelationIdNotProvided|EventId: 2|url: |action: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomerService : ICustomerService | |
{ | |
private readonly SampleApiDb database; | |
public CustomerService(SampleApiDb database) | |
{ | |
this.database = database; | |
} | |
public async Task<string> CreateStripeCustomer( | |
CreateCustomerRequestViewModel request) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomerRepository : RepositoryBase<SampleDBContext>, IRespository<Guid, Customer> | |
{ | |
public CustomerRepository(SubscriptionDBContext _context) : base(_context) | |
{ | |
} | |
public void Create(Customer customer) | |
{ | |
Context.Customers.Add(customer); | |
} | |
public void Delete(Guid id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class RepositoryBase<TContext> where TContext : DbContext | |
{ | |
public TContext Context { get; set; } | |
public RepositoryBase(TContext context) | |
{ | |
Context = context; | |
} | |
public IQueryable<T2> Procedure<T2>(string name, params DbParameter[] parameters) where T2 : class | |
{ | |
var sqlParameters = new List<SqlParameter>(); |