Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / FetchData.razor
Created November 26, 2020 08:01
Blazor oraz .NET 5
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@danielplawgo
danielplawgo / DataContext.cs
Created November 6, 2020 08:11
Optymistyczna współbieżność w EF Core
public class DataContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=.\SQLEXPRESS;Database=EFCoreOptimisticConcurrency;Trusted_Connection=True;");
}
public DbSet<Product> Products { get; set; }
}
@danielplawgo
danielplawgo / azure-pipelines.yml
Created October 26, 2020 05:35
Azure Logic App - wdrażanie
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
@danielplawgo
danielplawgo / GetWeather.cs
Created September 29, 2020 04:23
Azure Logic App - koszty
using System;
using System.Threading.Tasks;
using System.Net.Http;
private static HttpClient httpClient = new HttpClient();
public static void Run(TimerInfo myTimer, ILogger log, out string outputBlob)
{
var response = httpClient.GetAsync("http://api.openweathermap.org/data/2.5/weather?q=olsztyn,pl&APPID=4e61d7e7f40f9c3205722f24ebd3c2ac").Result;
outputBlob = response.Content.ReadAsStringAsync().Result;
@danielplawgo
danielplawgo / EFCoreMigrations.Migrator.csproj
Created March 27, 2020 04:58
EF Core uruchamianie migracji w Azure DevOps
<ItemGroup>
<ProjectReference Include="..\EFCoreMigrations.Web\EFCoreMigrations.Web.csproj" GlobalPropertiesToRemove="SelfContained" />
</ItemGroup>
@danielplawgo
danielplawgo / WebApiConfig.cs
Created November 18, 2019 04:54
Import WebApi do Postmana z użyciem Swagger
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Add only Json formatter for Postman import
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());
// Web API routes
config.MapHttpAttributeRoutes();
@danielplawgo
danielplawgo / AdminSettingsView.cs
Created October 9, 2019 04:32
Jak budować okno ustawień w aplikacji
public partial class AdminSettingsView : Window, ISettingsView
{
public AdminSettingsView()
{
InitializeComponent();
}
public double OrderNumber => 10;
public bool CanShow(ApplicationContext context)
@danielplawgo
danielplawgo / DatabaseRestoreService.cs
Created September 16, 2019 02:42
Uruchamianie migracji bazy w Azure DevOps
public class DatabaseRestoreService : IDatabaseRestoreService
{
private static NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
public Result Restore(string connectionString)
{
var connectionBuilder = new SqlConnectionStringBuilder(connectionString);
var databaseName = connectionBuilder.InitialCatalog;
_logger.Info($"Restore snapshot for {databaseName} database");
@danielplawgo
danielplawgo / Models.cs
Created September 10, 2019 03:28
Respawn - usuwanie danych z bazy
public class BaseModel
{
public BaseModel()
{
IsActive = true;
}
public int Id { get; set; }
public bool IsActive { get; set; }
@danielplawgo
danielplawgo / DatabaseRestoreService.cs
Last active September 9, 2019 09:39
Jak użyć Sql Server Snapshots do resetowania danych w testach
public class DatabaseRestoreService : IDatabaseRestoreService
{
private Lazy<DataContext> _dataContext;
protected DataContext DataContext => _dataContext.Value;
public DatabaseRestoreService(Lazy<DataContext> dataContext)
{
_dataContext = dataContext;