public ActionResult EnterpriseConnect()
        {
            var token = CronofyHelper.GetEnterpriseConnectOAuthToken(Request.QueryString["code"]);

            CronofyHelper.SetToken(token, true);

            var userInfo = CronofyHelper.GetEnterpriseConnectUserInfo();

            var recordCount = Convert.ToInt32(DatabaseHandler.Scalar("SELECT COUNT(*) FROM UserCredentials WHERE CronofyUID=@cronofyUid AND ServiceAccount=1",
                                                                     new Dictionary <string, object> {
                { "cronofyUid", userInfo.Sub }
            }));

            if (recordCount == 0)
            {
                DatabaseHandler.ExecuteNonQuery("INSERT INTO UserCredentials(CronofyUID, AccessToken, RefreshToken, ServiceAccount) VALUES(@cronofyUid, @accessToken, @refreshToken, 1)",
                                                new Dictionary <string, object> {
                    { "cronofyUid", userInfo.Sub }, { "accessToken", token.AccessToken }, { "refreshToken", token.RefreshToken }
                });
                LogHelper.Log(String.Format("Create enterprise connect user credentials record - sub=`{0}`", userInfo.Sub));
            }
            else
            {
                DatabaseHandler.ExecuteNonQuery("UPDATE UserCredentials SET AccessToken=@accessToken, RefreshToken=@refreshToken WHERE CronofyUID=@cronofyUid",
                                                new Dictionary <string, object> {
                    { "accessToken", token.AccessToken }, { "refreshToken", token.RefreshToken }, { "cronofyUid", userInfo.Sub }
                });
                LogHelper.Log(String.Format("Update enterprise connect user credentials record - sub=`{0}`", userInfo.Sub));
            }

            Response.SetCookie(new HttpCookie(CronofyHelper.EnterpriseConnectCookieName, userInfo.Sub));

            return(new RedirectResult("/enterpriseconnect"));
        }