Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / DataContext.cs
Created Nov 6, 2020
Optymistyczna współbieżność w EF Core
View DataContext.cs
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 Oct 26, 2020
Azure Logic App - wdrażanie
View azure-pipelines.yml
# 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 Sep 29, 2020
Azure Logic App - koszty
View GetWeather.cs
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 Mar 27, 2020
EF Core uruchamianie migracji w Azure DevOps
View EFCoreMigrations.Migrator.csproj
<ItemGroup>
<ProjectReference Include="..\EFCoreMigrations.Web\EFCoreMigrations.Web.csproj" GlobalPropertiesToRemove="SelfContained" />
</ItemGroup>
@danielplawgo
danielplawgo / WebApiConfig.cs
Created Nov 18, 2019
Import WebApi do Postmana z użyciem Swagger
View WebApiConfig.cs
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 Oct 9, 2019
Jak budować okno ustawień w aplikacji
View AdminSettingsView.cs
public partial class AdminSettingsView : Window, ISettingsView
{
public AdminSettingsView()
{
InitializeComponent();
}
public double OrderNumber => 10;
public bool CanShow(ApplicationContext context)
@danielplawgo
danielplawgo / DatabaseRestoreService.cs
Created Sep 16, 2019
Uruchamianie migracji bazy w Azure DevOps
View DatabaseRestoreService.cs
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 Sep 10, 2019
Respawn - usuwanie danych z bazy
View Models.cs
public class BaseModel
{
public BaseModel()
{
IsActive = true;
}
public int Id { get; set; }
public bool IsActive { get; set; }
@danielplawgo
danielplawgo / DatabaseRestoreService.cs
Last active Sep 9, 2019
Jak użyć Sql Server Snapshots do resetowania danych w testach
View DatabaseRestoreService.cs
public class DatabaseRestoreService : IDatabaseRestoreService
{
private Lazy<DataContext> _dataContext;
protected DataContext DataContext => _dataContext.Value;
public DatabaseRestoreService(Lazy<DataContext> dataContext)
{
_dataContext = dataContext;
@danielplawgo
danielplawgo / azure-pipelines.yml
Created Aug 26, 2019
Postman - uruchamianie testów w Azure DevOps
View azure-pipelines.yml
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.Repository.LocalPath)/Tests'
artifact: 'Tests'
You can’t perform that action at this time.