public async Task <Result <T> > GetById(int id) { var entity = await context.Set <T>().FindAsync(id); if (entity == null) { return(CommonResults.NotFound <T>(id)); } return(Result.Ok(entity)); }
public async Task <Result> EnsureExists(int id) { var exists = await Exists(id); return(exists ? Result.Ok() : CommonResults.NotFound <T>(id)); }
public async Task <Result <T> > GetById(int id) { var entity = await GetByIdOrNull(id); return(entity == null?CommonResults.NotFound <T>(id) : Result.Ok(entity)); }