public static int?ExecuteActionImplementation(ActionModel model)
        {
            if (model.ActionID == -1)
            {
                int?actionID = Create(model);
                if (!actionID.HasValue)
                {
                    return(null);
                }

                model.ActionID = actionID.Value;
            }

            DirectContainer dc        = model.Database.LoadContainer("SELECT * FROM [].tm_lead_action WHERE actionid=" + model.ActionID);
            LeadEntry       leadEntry = LeadManager.ManageLeadFromAction(model);

            if ((model.Event == ActionModelEvent.Redirection || model.Event == ActionModelEvent.InputEmail) && !dc.GetBoolean("input_redirect"))
            {
                ActionManager.Update(model, "input_redirect", "1", dc);
            }
            if (model.Event == ActionModelEvent.Create)
            {
                ActionManager.Update(model, "input_redirect", "1", dc);
            }
            if ((model.Event == ActionModelEvent.InputEmail && !dc.GetBoolean("input_email")) || (dc.GetBoolean("input_email") == false && !string.IsNullOrEmpty(leadEntry.Container.GetString("email"))))
            {
                ActionManager.Update(model, "input_email", "1", dc);
            }
            if ((model.Event == ActionModelEvent.InputContact && !dc.GetBoolean("input_contact")) || (dc.GetBoolean("input_contact") == false && !string.IsNullOrEmpty(leadEntry.Container.GetString("first_name")) && !string.IsNullOrEmpty(leadEntry.Container.GetString("last_name"))))
            {
                ActionManager.Update(model, "input_contact", "1", dc);
            }
            if (model.Event == ActionModelEvent.Subscribe)
            {
                ActionManager.Update(model, "has_subscription", "1", dc);
            }
            if (model.Event == ActionModelEvent.Chargeback)
            {
                ActionManager.Update(model, "has_chargeback", "1", dc);
            }
            if (model.Event == ActionModelEvent.Refund)
            {
                ActionManager.Update(model, "has_refund", "1", dc);
            }
            if (model.Event == ActionModelEvent.Charge)
            {
                ActionManager.Update(model, "times_charged", "++", dc);
            }
            if (model.Event == ActionModelEvent.Upsell)
            {
                ActionManager.Update(model, "times_upsell", "++", dc);
            }
            if (model.Event == ActionModelEvent.EndFlow)
            {
                ActionManager.Update(model, "provider_redirection", model.ProviderRedirection, dc);
                ActionManager.Update(model, "has_redirectedToProvider", "1", dc);
            }

            if (model.Service != ActionService.Default && (!dc.GetInt("serviceid").HasValue || (int)model.Service != dc.GetInt("serviceid").Value))
            {
                ActionManager.Update(model, "serviceid", ((int)model.Service).ToString(), dc);
            }
            if (!string.IsNullOrEmpty(model.ClickID) && !dc.GetString("clickid").Equals(model.ClickID))
            {
                ActionManager.Update(model, "clickid", model.ClickID, dc);
            }
            if (model.AffID.HasValue && (!dc.GetInt("affid").HasValue || (dc.GetInt("affid").HasValue&& model.AffID.Value != dc.GetInt("affid").Value)))
            {
                ActionManager.Update(model, "affid", model.AffID.ToString(), dc);
            }
            if (!string.IsNullOrEmpty(model.PubID) && !dc.GetString("pubid").Equals(model.PubID))
            {
                ActionManager.Update(model, "pubid", model.PubID, dc, true);
            }
            if (!string.IsNullOrEmpty(model.LanderUrl) && (string.IsNullOrEmpty(dc.GetString("lander_url")) || !dc.GetString("lander_url").Equals(model.LanderUrl)))
            {
                ActionManager.Update(model, "lander_url", model.LanderUrl, dc, true);
            }

            int?landerID = CCSubmitCacheManager.GetLanderID(model.LanderName, model.Database);

            if (landerID.HasValue && dc.GetInt("landerid").HasValue&& dc.GetInt("landerid").Value != landerID.Value)
            {
                ActionManager.Update(model, "landerid", landerID.Value.ToString(), dc);
            }

            model.SQLUpdateQuery = "UPDATE [].tm_lead_action SET " + model.SQLUpdateQuery + " updated=CURRENT_TIMESTAMP WHERE actionid=" + model.ActionID + ";";
            model.Database.Transactional.Execute(model.SQLUpdateQuery);
            model.Database.Transactional.Run();

            return(model.ActionID);
        }