Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / azure-pipelines.yml
Created Apr 3, 2022
Uruchamianie Terraform w Azure DevOps
View azure-pipelines.yml
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.Repository.LocalPath)/src'
@danielplawgo
danielplawgo / AddProducts.cs
Created Feb 15, 2022
EF Core 6 Temporal Tables
View AddProducts.cs
public partial class AddProducts : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
@danielplawgo
danielplawgo / applicationinsights.tf
Created Oct 28, 2021
Terraform i Azure - przykład
View applicationinsights.tf
resource "azurerm_application_insights" "app_insight" {
name = "onlin-ai-${var.env}"
location = azurerm_resource_group.resource_group.location
resource_group_name = azurerm_resource_group.resource_group.name
application_type = "web"
}
View main1.tf
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.46.0"
}
}
required_version = ">= 0.14.9"
}
@danielplawgo
danielplawgo / AuditLog.cs
Created May 26, 2021
Entity Framework Core - DbFunction
View AuditLog.cs
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; }
}
@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')