public static SummaryModel Create(SummaryData data)
        {
            var model = new SummaryModel()
            {
                sessions = FormatInt(data.Sessions),

                conversions = FormatInt(data.Conversions),

                spend = FormatInt(data.Spend),

                conversionCosts = FormatDecimal(data.ConversionCosts),

                referringDomains = FormatInt(data.ReferringDomains),

                brandedSearches = FormatInt(data.BrandedSearches),

                socialTrend = FormatInt(data.SocialTrend),

                conversionRate = data.ConversionRate.ToString("0.0"),

                onlineSales = FormatInt(data.OnlineSales),

                users = FormatUsers(data.Sessions),

                ppc       = data.PPC,
                ppcTarget = data.PPCTarget,

                banners       = data.Banners,
                bannersTarget = data.BannersTarget,

                email       = data.Email,
                emailTarget = data.EmailTarget,

                thirdParty       = data.ThirdParty,
                thirdPartyTarget = data.ThirdPartyTarget,

                topPages = data.TopPages,
                keywords = data.Keywords
            };

            model.trafficStats = data.TrafficStats;

            model.trafficPerMedium = (from month in model.trafficStats
                                      select new MediumTraffic
            {
                title = month.title,
                session = month.session,
                conversion = month.conversion,
                organic = month.perMedium.Single(x => x.title == "organic").session,
                paid = month.perMedium.Single(x => x.title == "paid").session,
                direct = month.perMedium.Single(x => x.title == "direct").session,
                referral = month.perMedium.Single(x => x.title == "referral").session,
                email = month.perMedium.Single(x => x.title == "email").session,
            }).ToArray();

            return(model);
        }
Esempio n. 2
0
        public static IList <SummaryData> CreateCollection(SummaryDataRepository repository)
        {
            List <SummaryData> models = new List <SummaryData>();

            SummaryData start = SummaryData.Create(repository);
            SummaryData end   = SummaryData.Create(repository);

            models.Add(start);
            models.Add(end);

            return(models);
        }
Esempio n. 3
0
        public static SummaryData Create(SummaryDataRepository repository)
        {
            int          conversions    = repository.GetConversions();
            int          sessions       = repository.GetSessions();
            decimal      conversionRate = ((decimal)conversions / (decimal)sessions) * 100;
            CampaignData data           = repository.GetCampaignData(conversions);

            SummaryData returnValue = new SummaryData()
            {
                Sessions = sessions,

                Conversions = conversions,

                Spend = repository.GetSpend(),

                ConversionCosts = repository.GetConversionCosts(),

                ReferringDomains = repository.GetReferringDomains(),

                BrandedSearches = repository.GetBrandedSearches(),

                SocialTrend = repository.GetSocialTrend(),

                ConversionRate = conversionRate,

                OnlineSales = repository.GetOnlineSales(),

                Users = sessions,

                PPC       = data.PPC,
                PPCTarget = data.PPCTarget,

                Banners       = data.Banners,
                BannersTarget = data.BannersTarget,

                Email       = data.Email,
                EmailTarget = data.EmailTarget,

                ThirdParty       = data.ThirdParty,
                ThirdPartyTarget = data.ThirdPartyTarget,

                TopPages = repository.GetPageList(),
                Keywords = repository.GetWordList(),

                TrafficStats = repository.GetTrafficStats(sessions, conversions)
            };

            return(returnValue);
        }