public UserEntity AddUser(UserEntity user) { try { int userId = _userEngine.AddUser(user); user = _userEngine.GetUser(userId); if (user == null) { throw new Exception("Error while writing a new user to DB."); } _userEngine.AddUserToCache(user); return(user); } catch (Exception e) { _exceptionHandlerLogic.LogExceptionAsync(e); throw e; } }