I’m trying to understand how to correctly use AutoFilter to apply the currently logged in users Id to my query. However, the best I’ve got is the following, which has an error due to type miss match. The AppUserId field here links to the IAuthRepo (custom)
public class Aircraft : AuditBase, IAppUserFilter
{
[AutoIncrement]
public int Id { get; set; }
public string Registration { get; set; }
public int AppUserId { get; set; }
}
public interface IAppUserFilter
{
int AppUserId { get; set; }
}
[Tag("Aircraft"), Description("Find Aircraft")]
[Route("/aircraft", "GET")]
[Route("/aircraft/{Id}", "GET")]
[ValidateIsAuthenticated]
[AutoApply(Behavior.AuditQuery)]
[AutoFilter(QueryTerm.Ensure, nameof(IAppUserFilter.AppUserId), Eval = "userAuthId")]
public class QueryAircraft : QueryDb<Aircraft>
{
public int? Id { get; set; }
}
I tried adding |> toInt but it didn’t work (or i used it wrong).