Skip to content

Instantly share code, notes, and snippets.

View diegobrunetti's full-sized avatar

Diego Brunetti Teixeira diegobrunetti

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace DiegoOnSoftware.CommonDomainTypes
{
public class Cpf
{
private readonly string _pattern = @"\d{11}$";
@diegobrunetti
diegobrunetti / DomainEvents.cs
Last active May 13, 2019 10:41
A modified version of Udi Dahan's domain events dispatcher using AsyncLocal, so we don't get in trouble with Asp.Net and async/await. Original code: http://udidahan.com/2009/06/14/domain-events-salvation/
using System;
using System.Collections.Generic;
using System.Threading;
namespace DomainEvents
{
public static class DomainEvents
{
private static AsyncLocal<List<Delegate>> actions = new AsyncLocal<List<Delegate>>();
{
referrals: 0,
summary: {
referred: 0,
contacted: 0,
invalidated: 0,
converted: 0
}
}
[HttpGet, Route("api/posts/{permalink}")]
public async Task<object> PostWithPermalink(string permalink)
{
var post = await _repository.FindAsync(permalink);
if (post != null)
{
return new
{
title = post.Title,