Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / ConnectionStringBuilder.cs
Created May 7, 2021
Multi Tenant - jedna baza danych per tenant
View ConnectionStringBuilder.cs
public class ConnectionStringBuilder : IConnectionStringBuilder
{
private readonly ITenantAccessService _tenantAccessService;
private readonly IConfiguration _configuration;
public ConnectionStringBuilder(ITenantAccessService tenantAccessService,
IConfiguration configuration)
{
_tenantAccessService = tenantAccessService;
_configuration = configuration;
@danielplawgo
danielplawgo / BasePage.cs
Created May 5, 2021
Blazor - walidacja - Web API
View BasePage.cs
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 / ClaimResolutionStrategy.cs
Created Apr 7, 2021
Multi tenant - określenie tenanta
View ClaimResolutionStrategy.cs
public class ClaimResolutionStrategy : ITenantResolutionStrategy
{
private readonly IHttpContextAccessor _httpContextAccessor;
public ClaimResolutionStrategy(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public Task<Guid> GetTenantIdentifierAsync()
@danielplawgo
danielplawgo / database1.sql
Last active Mar 24, 2021
SQL Server i Docker
View database1.sql
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 / DecoratorAttribute.cs
Created Mar 9, 2021
Scrutor użycie dekoratora
View DecoratorAttribute.cs
public class DecoratorAttribute : Attribute
{
}
@danielplawgo
danielplawgo / IRepository.cs
Created Mar 2, 2021
Scrutor auto rejestracja typów
View IRepository.cs
public interface IRepository
{
}
@danielplawgo
danielplawgo / azurepipelines1.yml
Last active Feb 16, 2021
Azure DevOps path filters
View azurepipelines1.yml
# 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:
View ProcessResponse.cs
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 / SendGridConfig.cs
Created Feb 2, 2021
SendGrid - wysyłka wiadomości email
View SendGridConfig.cs
public class SendGridConfig
{
public string ApiKey { get; set; }
public string SenderEmail { get; set; }
public string SenderName { get; set; }
}