Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / ProcessResponse.cs
Created February 10, 2021 07:28
SendGrid - Webhook
private async Task<IActionResult> ProcessResponse(Response response)
{
var responseContent = await response.Body.ReadAsStringAsync();
if (string.IsNullOrEmpty(responseContent) == false)
{
return BadRequest(responseContent);
}
var header = response.Headers.FirstOrDefault(h => h.Key == "X-Message-Id");
@danielplawgo
danielplawgo / azurepipelines1.yml
Last active February 16, 2021 05:05
Azure DevOps path filters
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- master
paths:
@danielplawgo
danielplawgo / IRepository.cs
Created March 2, 2021 07:26
Scrutor auto rejestracja typów
public interface IRepository
{
}
@danielplawgo
danielplawgo / DecoratorAttribute.cs
Created March 9, 2021 19:49
Scrutor użycie dekoratora
public class DecoratorAttribute : Attribute
{
}
@danielplawgo
danielplawgo / database1.sql
Last active March 24, 2021 19:45
SQL Server i Docker
IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'Database1')
BEGIN
CREATE DATABASE [Database1]
END
GO
USE [Database1]
GO
--You need to check if the table exists
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='Users' and xtype='U')
@danielplawgo
danielplawgo / requests.rest
Created April 2, 2021 04:16
Visual Studio Code REST Client
@danielplawgo
danielplawgo / ClaimResolutionStrategy.cs
Created April 7, 2021 03:49
Multi tenant - określenie tenanta
public class ClaimResolutionStrategy : ITenantResolutionStrategy
{
private readonly IHttpContextAccessor _httpContextAccessor;
public ClaimResolutionStrategy(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public Task<Guid> GetTenantIdentifierAsync()
@danielplawgo
danielplawgo / BasePage.cs
Created May 5, 2021 06:29
Blazor - walidacja - Web API
public class BasePage : ComponentBase
{
protected FormValidator FormValidator;
protected void ShowError(Result result, object model = null)
{
FormValidator?.ShowError(result, model);
}
protected void ShowMessage(string message)
@danielplawgo
danielplawgo / ConnectionStringBuilder.cs
Created May 7, 2021 04:24
Multi Tenant - jedna baza danych per tenant
public class ConnectionStringBuilder : IConnectionStringBuilder
{
private readonly ITenantAccessService _tenantAccessService;
private readonly IConfiguration _configuration;
public ConnectionStringBuilder(ITenantAccessService tenantAccessService,
IConfiguration configuration)
{
_tenantAccessService = tenantAccessService;
_configuration = configuration;
@danielplawgo
danielplawgo / AuditLog.cs
Created May 26, 2021 12:32
Entity Framework Core - DbFunction
public class AuditLog
{
public Guid Id { get; set; } = Guid.NewGuid();
public DateTimeOffset Created { get; set; } = DateTimeOffset.UtcNow;
public string LogType { get; set; }
public string Data { get; set; }
}