public async Task <SingleResponse <User> > GetById(int id) { if (NullPropertyVerifier.IsIdValid(id)) { return(await _userDAL.GetById(id)); } return(await SingleResponseModels <User> .FailedSingleModel($"{id.toString()} is not a valid ID.")); }
public async Task <SingleResponse <User> > GetById(int id) { try { using var context = _db; var user = await context .Users .FirstOrDefaultAsync(u => u.Id == id); return(await SingleResponseModels <User> .SuccessSingleModel(user)); } catch (Exception e) { return(await SingleResponseModels <User> .FailedSingleModel(e.ToString())); } }