public ActionResult <ItemResponse <Provider> > SelectDetailsById(int id) { int code = 200; BaseResponse response; try { IUserAuthData user = _auth.GetCurrentUser(); Provider provider = null; if (user.Roles.Contains("SysAdmin")) { provider = _service.SelectDetailsById(id); } if (!user.Roles.Contains("Consumer") && !user.Roles.Contains("SysAdmin")) { if (user.Roles.Contains("Provider")) //provider is making request { provider = _service.SelectDetailsById(id); } else //office manager or provider assistant is making request { provider = _service.SelectDetailsById(id, user.Id); } } if (provider == null) { code = 404; response = new ErrorResponse("App resource not found."); } else { response = new ItemResponse <Provider>() { Item = provider }; } } catch (Exception ex) { code = 500; response = new ErrorResponse(ex.Message); base.Logger.LogError(ex.ToString()); } return(StatusCode(code, response)); }