Exemplo n.º 1
0
 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."));
 }
Exemplo n.º 2
0
        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()));
            }
        }