This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetOrderQueryHandler | |
{ | |
. | |
. | |
. | |
public async Task<OrderDto> Handle(GetOrderQuery request, CancellationToken cancellationToken) | |
{ | |
var order = await _repository.Get(request.OrderId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.Serialization; | |
[Serializable] | |
// Used for HttpStatusCode 404 (NotFound) | |
public class ResourceNotFoundException : Exception | |
{ | |
public ResourceNotFoundException(string message) : base(message) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ErrorResponse | |
{ | |
public HttpStatusCode StatusCode { get; set; } | |
public string Title { get; set; } | |
public string Exception { get; set; } | |
public List<ErrorEntry> Entries { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Mime; | |
using System.Text.Json; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Logging; | |
public class ApplicationExceptionMiddleware | |
{ | |
private readonly RequestDelegate _next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPatch] | |
public async Task<IActionResult> Update([FromBody] OrderDto order) | |
{ | |
try | |
{ | |
if (!ModelState.IsValid) | |
{ | |
// Returns response of type `ModelState` on "Bad Request" | |
return BadRequest(ModelState); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Security.Cryptography.X509Certificates; | |
public static class CertificateExtensions | |
{ | |
// Private certificatePath: $"/var/ssl/private/{thumbprint}.p12" | |
// Public certificatePath: $"/var/ssl/certs/{thumbprint}.der" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.Extensions.Logging.Abstractions; | |
using Xunit; | |
using Xunit.Abstractions; | |
namespace PostgreSQLDistributedLock.Tests | |
{ | |
public class DistributedLockTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Logging; | |
using Npgsql; | |
namespace PostgreSQLDistributedLock | |
{ | |
public sealed class DistributedLock : IDisposable | |
{ | |
private readonly ILogger<DistributedLock> _logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddHostedService<SchedulerService>(); | |
services.AddScoped<IScopedSchedulerService, ScopedSchedulerService>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Cronos; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
namespace SchedulerJobSample.Worker | |
{ |