parent
084b9bc640
commit
8f24643bbf
|
@ -108,23 +108,23 @@ app.MapPut("/todoitems/{id}", async (Todo inputTodo, int id, TodoDb db) =>
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
return Results.NoContent();
|
return Results.NoContent();
|
||||||
}).AddEndpointFilterFactory(async (filterFactoryContext, next) =>
|
}).AddEndpointFilterFactory((filterFactoryContext, next) =>
|
||||||
{
|
{
|
||||||
var parameters = context.MethodInfo.GetParameters();
|
var parameters = filterFactoryContext.MethodInfo.GetParameters();
|
||||||
if (parameters.Length >= 1 && parameters[0].ParameterType == typeof(Todo))
|
if (parameters.Length >= 1 && parameters[0].ParameterType == typeof(Todo))
|
||||||
{
|
{
|
||||||
return async invocationContext =>
|
return async invocationContext =>
|
||||||
{
|
{
|
||||||
var todoParam = invocationContext.GetArgument<Todo>(0);
|
var todoParam = invocationContext.GetArgument<Todo>(0);
|
||||||
|
|
||||||
var validationError = Utilities.IsValid(tdparam);
|
var validationError = Utilities.IsValid(todoParam);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(validationError))
|
if (!string.IsNullOrEmpty(validationError))
|
||||||
{
|
{
|
||||||
return Results.Problem(validationError);
|
return Results.Problem(validationError);
|
||||||
}
|
}
|
||||||
return await next(invocationContextContext);
|
return await next(invocationContext);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return invocationContext => next(invocationContext);
|
return invocationContext => next(invocationContext);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue