public BulkEmailSplitServiceResponse StartSplitTest(Guid splitTestId, string startDate, bool startManual)
        {
            var response         = new BulkEmailSplitServiceResponse();
            var validationResult = SplitTestValidator.Validate(splitTestId);

            if (!validationResult.Success)
            {
                response.Message = validationResult.Message;
                return(response);
            }
            DateTime startDateValue;

            if (!DateTime.TryParse(startDate, out startDateValue))
            {
                return(null);
            }
            UpdateBulkEmail(splitTestId, MarketingConsts.BulkEmailStatusStartPlanedId,
                            startDateValue.ToUniversalTime());
            Guid statusId = startManual
                                ? MarketingConsts.BulkEmailSplitStatusLaunchedId
                                : MarketingConsts.BulkEmailSplitStatusStartPlanedId;

            SetSplitTestStatus(splitTestId, statusId);
            response.Success  = true;
            response.StatusId = statusId;
            return(response);
        }
        public BulkEmailSplitServiceResponse AbandonSplitTest(Guid splitTestId)
        {
            var result      = new BulkEmailSplitServiceResponse();
            var selectCount = new Select(UserConnection)
                              .Column(Func.Count("Id"))
                              .From("BulkEmail")
                              .Where("SplitTestId").IsEqual(Column.Parameter(splitTestId))
                              .And("StatusId").IsNotEqual(Column.Parameter(MarketingConsts.BulkEmailStatusStartPlanedId))
                              as Select;
            var count = selectCount.ExecuteScalar <int>();

            if (count > 0)
            {
                return(result);
            }
            UpdateBulkEmail(splitTestId, MarketingConsts.BulkEmailStatusPlannedId, DateTime.MinValue);
            SetSplitTestStatus(splitTestId, MarketingConsts.BulkEmailSplitStatusPlannedId);
            result.Success  = true;
            result.StatusId = MarketingConsts.BulkEmailSplitStatusPlannedId;
            return(result);
        }