private List <EmailIndicator> GetEmailIndicatorList(EmailStateRequest filters)
        {
            var             response        = new List <EmailIndicator>();
            var             sessionId       = Guid.NewGuid();
            StoredProcedure storedProcedure = CreateStoredProcedure(filters, sessionId);
            Select          select          = CreateSessionSelect(sessionId);
            Delete          delete          = CreateSessionDelete(sessionId);

            using (DBExecutor dbExecutor = UserConnectionSafe.EnsureDBConnection()) {
                storedProcedure.Execute(dbExecutor);
                using (var reader = select.ExecuteReader(dbExecutor)) {
                    while (reader.Read())
                    {
                        var emailStateItem = new EmailIndicator();
                        emailStateItem.Caption = reader.GetColumnValue <string>("Caption");
                        object benchmarkValue = reader["Benchmark"];
                        if (benchmarkValue != DBNull.Value)
                        {
                            emailStateItem.Benchmark = UserConnectionSafe.DBTypeConverter.DBValueToInt(benchmarkValue);
                        }
                        object actualCountValue = reader["ActualCount"];
                        if (actualCountValue != DBNull.Value)
                        {
                            emailStateItem.ActualValue = UserConnectionSafe.DBTypeConverter.DBValueToInt(actualCountValue);
                        }
                        emailStateItem.State = reader.GetColumnValue <string>("State");
                        response.Add(emailStateItem);
                    }
                }
                delete.Execute(dbExecutor);
            }
            return(response);
        }
        private StoredProcedure CreateStoredProcedure(EmailStateRequest filters, Guid sessionId)
        {
            var storedProcedure = new StoredProcedure(UserConnectionSafe, "tsp_CreateEmailIndicators");

            storedProcedure.WithParameter("sessionId", sessionId);
            TryCreateParameter(storedProcedure, "emailId", filters.EmailId);
            TryCreateParameter(storedProcedure, "startDate", filters.StartDate);
            TryCreateParameter(storedProcedure, "endDate", filters.EndDate);
            return(storedProcedure);
        }
 public List <EmailIndicator> GetEmailState(EmailStateRequest filters)
 {
     PrepareCorsHeaders();
     Authenticate();
     return(GetEmailIndicatorList(filters));
 }