protected UserModel GetUserModel(ISession s, bool styles = false) { return(new Cache().GetOrGenerate(CacheKeys.USER + "~" + styles, x => { x.LifeTime = LifeTime.Request /*Session*/; var id = User.Identity.GetUserId(); var user = _UserAccessor.GetUserById(s, id); //if (styles) { // user._StylesSettings = s.Get<UserStyleSettings>(id); //} return user; })); }
public Response <User> GetUserInfo(GetUserByUserIdRequest request) { Response <User> response = new Response <User>(); if (request == null || request.UserID == 0) { ArgumentNullException ex = new ArgumentNullException("GetUserInfo request"); LogError(ex); response.ErrorCode = ErrorCode.Argument; response.Exception = ex; return(response); } try { UserAccessor accessor = new UserAccessor(); response.Result = accessor.GetUserById(request.UserID); if (response.Result == null) { response.IsSuccess = false; response.ErrorCode = ErrorCode.DataEffective; } else { response.IsSuccess = true; } } catch (Exception ex) { LogError(ex); response.IsSuccess = false; response.ErrorCode = ErrorCode.Technical; } return(response); }