mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
22 lines
674 B
C#
22 lines
674 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Api.SeaHavenIndustries.Filters
|
|
{
|
|
public class ConcurrencyExceptionFilter : IExceptionFilter
|
|
{
|
|
public void OnException(ExceptionContext context)
|
|
{
|
|
if (context.Exception is not DbUpdateConcurrencyException) return;
|
|
|
|
context.Result = new ConflictObjectResult(new
|
|
{
|
|
status = "Conflict",
|
|
message = "The record was modified by another user. Refresh and retry.",
|
|
code = 409
|
|
});
|
|
context.ExceptionHandled = true;
|
|
}
|
|
}
|
|
}
|