Skip to content

Instantly share code, notes, and snippets.

@killnine
killnine / Customer.cs
Created November 20, 2023 14:48 — forked from SteveSandersonMS/Customer.cs
Blazor + FluentValidation example
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Address Address { get; } = new Address();
public List<PaymentMethod> PaymentMethods { get; } = new List<PaymentMethod>();
}
public class Address
{
@killnine
killnine / APM_Span_Example.cs
Created March 26, 2020 20:39
Creating multiple spans within a transaction for Elastic APM
[HttpGet]
public async Task<IActionResult> TraceSingleBlockCall()
{
await Agent.Tracer.CaptureTransaction("TraceSingleBlockCall", "Request", async (transaction) =>
{
transaction.Labels["Foo"] = "Bar";
//Unit of work 1
await Agent.Tracer.CurrentTransaction.CaptureSpan("Unit of Work 1", "TraceSingleBlockCall", async (span) =>
{
@killnine
killnine / SongCollectionController.cs
Last active September 28, 2019 19:57
Handling REST collections of child entities...
/*
When a user posts multiple songs to the controller, I want it to redirect back to
the Get endpoint. However, I don't believe asp.net's Routing handles that.
*/
[Route("api/songbooks/{songbookId}/songcollections")]
public class SongCollectionController : Controller
{
[HttpGet("{id}", Name = "GetSongCollection")]
public IActionResult GetSongCollection(Guid songbookId, [ModelBinder(BinderType = typeof(ArrayModelBinder))]IEnumerable<Guid> ids)
@killnine
killnine / oooAdjustments.md
Created April 21, 2015 16:50
Adjustment Order of Operations

Rule

Gross >= Net + MR

Other Info

Users can make individual adjustments to Gross, Net, and Makeready as long as the primary business rule is maintained.

Currently, the adjustments are made one at a time and always in the same order (Gross first, then Net, finally MR). This causes issues in certain situations

@killnine
killnine / 01_GroupByLocation.cs
Last active August 29, 2015 14:16
Ordering by secondary group
/*
This should return a collection where you can create the following tree:
Location 1
|__ Machine 1
|__ Machine 2
Location 2
|__ Machine 3
|__ Machien 4
*/
@killnine
killnine / SignalRUrlReservation.bat
Created January 7, 2015 04:30
SignalR URL Reservation
@echo Run me as administrator
netsh advfirewall firewall delete rule name="YourSignalRService (SignalR)"
netsh advfirewall firewall add rule name="YourSignalRService (SignalR)" dir=in action=allow protocol=TCP localport=6790
netsh http add urlacl url=http://+:6790/ user=Users
@killnine
killnine / createTask.sql
Created December 12, 2014 19:03
SQL Bug
/* Original Version */
UPDATE Task
SET
Comment = #Comment#,
TaskStatus = #Status#,
TaskState = #State#,
JobNumber = #JobNumber#,
ExternalJobNumber = #ExternalJobNumber#
WHERE TaskId = #TaskId#
@killnine
killnine / MultipleDialogs.cs
Created November 5, 2014 15:39
Multiple dialogs...
/* Creates first dialog */
Messenger.Default.Send(new DialogMessageAction<MessageDialogResult>("The current Task has not met its target Net. Are you sure you wish to continue and underrun the Task?", "Underrun Warning", userSelection =>
{
if (userSelection == MessageDialogResult.Affirmative) /* Complete Task */
{
/* Within the callback of the first dialog, the second is created */
Messenger.Default.Send(new DialogMessageAction<string>("Please explain reason for underrun (Required)", "Underrun Comment", comment =>
{
if (string.IsNullOrEmpty(comment))
//Setup
DateTime localDateTime = new DateTime(2014,10,30,9,6,30,DateTimeKind.Local);
string timeZoneDescription = "Eastern Standard Time";
//Execution
TimeZoneInfo localizedTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneDescription);
var universalTime = TimeZoneInfo.ConvertTimeToUtc(localDateTime, localizedTimeZoneInfo); //This throws an exception, see below!
return universalTime;
/*
<ListBox ItemsSource="{Binding FilteredOperationCodes, Mode=OneWay}" SelectedItem="{Binding SelectedOperationCode}" SelectionMode="Single">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="200" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>