private List <AffiliateReferralsViewModel.ReferalViewModel> GetReferrals(Affiliate aff,
                                                                                 AffiliateReportCriteria.SearchType searchBy, string searchText, int pageNumber, int pageSize,
                                                                                 out int totalRowCount)
        {
            var criteria = new AffiliateReportCriteria
            {
                SearchBy            = searchBy,
                SearchText          = searchText,
                ReferralAffiliateID = aff.AffiliateId
            };
            var total     = 0;
            var referrals = HccApp.ContactServices.Affiliates.FindAllWithFilter(criteria, pageNumber, pageSize,
                                                                                ref total);

            totalRowCount = total;

            return(referrals
                   .Select(r => new AffiliateReferralsViewModel.ReferalViewModel
            {
                Id = r.AffiliateId,
                Name = r.FullName,
                Revenue = r.Commission.ToString("C"),
                Email = r.Email
            })
                   .ToList());
        }
Exemple #2
0
        public void Affiliate_TestFindAllWithFilter()
        {
            using (ShimsContext.Create())
            {
                InitShims();

                var hccApp = CreateHccAppInMemory();
                var target = hccApp.ContactServices.Affiliates;

                // Create 3 affiliates
                var aff1 = new Affiliate {
                    StoreId = 2, AffiliateId = "a001", Username = "******"
                };
                var aff2 = new Affiliate
                {
                    StoreId             = 2,
                    AffiliateId         = "a002",
                    Username            = "******",
                    ReferralAffiliateId = "a001"
                };
                var aff3 = new Affiliate
                {
                    StoreId             = 2,
                    AffiliateId         = "a003",
                    Username            = "******",
                    ReferralAffiliateId = "a001"
                };

                var status = CreateUserStatus.None;
                target.Create(aff1, ref status);
                target.Create(aff2, ref status);
                target.Create(aff3, ref status);

                // Add orders using affiliateid
                var o = new Order {
                    AffiliateID = aff3.Id
                };
                var li = new LineItem
                {
                    BasePricePerItem = 19.99m,
                    ProductName      = "Sample Product",
                    ProductSku       = "ABC123",
                    Quantity         = 2
                };
                o.Items.Add(li);

                hccApp.OrderServices.Orders.Upsert(o);

                var rowCount = 0;
                var filter   = new AffiliateReportCriteria();
                var actual   = target.FindAllWithFilter(filter, 1, 10, ref rowCount);

                Assert.AreEqual(3, actual.Count);
                var actual1 = actual.FirstOrDefault(a => a.AffiliateId == "a001");
                var actual3 = actual.FirstOrDefault(a => a.AffiliateId == "a003");
                Assert.IsNotNull(actual1);
                Assert.AreEqual(2, actual1.SignupsCount);
                Assert.AreEqual(1, actual3.OrdersCount);
            }
        }
 public override AffiliateReportTotals GetAffiliateTotals(long affId, AffiliateReportCriteria criteria)
 {
     using (var strategy = CreateStrategy())
     {
         var helper = new AffiliateReportHelper(this, strategy, criteria, 1, int.MaxValue);
         return(helper.GetAffiliateTotals(affId));
     }
 }
 public override AffiliateReportTotals GetTotalsByFilter(AffiliateReportCriteria criteria,
                                                         TotalsReturnType returnType)
 {
     using (var strategy = CreateStrategy())
     {
         var helper = new AffiliateReportHelper(this, strategy, criteria, 1, int.MaxValue);
         return(helper.GetTotals(returnType));
     }
 }
 internal AffiliateReportHelper(DnnAffiliateRepository rep, IRepoStrategy <hcc_Affiliate> strategy,
                                AffiliateReportCriteria criteria, int pageNumber, int pageSize)
 {
     _rep           = rep;
     _strategy      = strategy;
     _criteria      = criteria;
     _pageNumber    = pageNumber;
     _pageSize      = pageSize;
     _storeId       = _rep.Context.CurrentStore.Id;
     _applyVATRules = _rep.Context.CurrentStore.Settings.ApplyVATRules;
 }
 public override List <AffiliateReportData> FindAllWithFilter(AffiliateReportCriteria criteria, int pageNumber,
                                                              int pageSize, ref int rowCount)
 {
     using (var strategy = CreateStrategy())
     {
         var helper = new AffiliateReportHelper(this, strategy, criteria, pageNumber, pageSize);
         var list   = helper.GetReport();
         rowCount = helper.RowCount;
         return(list);
     }
 }
Exemple #7
0
        private void LoadReferrals()
        {
            var criteria = new AffiliateReportCriteria
            {
                SearchBy            = (AffiliateReportCriteria.SearchType)ddlSearchBy.SelectedValue.ConvertTo <int>(),
                SearchText          = txtSearchText.Text,
                ReferralAffiliateID = Affiliate.AffiliateId
            };
            var totalRowCount = 0;
            var referrals     = HccApp.ContactServices.Affiliates.FindAllWithFilter(criteria, ucReferralPager.PageNumber,
                                                                                    ucReferralPager.PageSize, ref totalRowCount);

            ucReferralPager.SetRowCount(totalRowCount);

            gvReferrals.DataSource = referrals;
            gvReferrals.DataBind();
        }
Exemple #8
0
        private void LoadAffiliateDetails()
        {
            var aff = HccApp.ContactServices.Affiliates.Find(AffiliateId);

            PageTitle = aff.Address.FirstName + " " + aff.Address.LastName;
            Affiliate = aff;


            var thisMonth = new DateRange {
                RangeType = DateRangeType.ThisMonth
            };
            var criteria = new AffiliateReportCriteria
            {
                StartDateUtc = thisMonth.StartDate,
                EndDateUtc   = thisMonth.EndDate
            };

            TotalsByMonth = HccApp.ContactServices.Affiliates.GetAffiliateTotals(aff.Id, criteria);
            Totals        = HccApp.ContactServices.Affiliates.GetAffiliateTotals(aff.Id, new AffiliateReportCriteria());
        }
Exemple #9
0
        private AffiliateReportCriteria GetCriteria()
        {
            var utcStart        = ucDateRangePicker.GetStartDateUtc(HccApp);
            var utcEnd          = ucDateRangePicker.GetEndDateUtc(HccApp);
            var onlyNonApproved = rblFilterMode.SelectedValue == "OnlyNonApproved";
            var onlyOwed        = rblFilterMode.SelectedValue == "OnlyOwed";

            AffiliateReportCriteria criteria;

            if (onlyNonApproved)
            {
                criteria = new AffiliateReportCriteria
                {
                    ShowOnlyNonApproved = true,
                    SortBy = (AffiliateReportCriteria.SortingType)ddlSortBy.SelectedValue.ConvertTo <int>()
                };
            }
            else if (onlyOwed)
            {
                criteria = new AffiliateReportCriteria
                {
                    ShowCommissionOwed = true,
                    SortBy             = (AffiliateReportCriteria.SortingType)ddlSortBy.SelectedValue.ConvertTo <int>()
                };
            }
            else
            {
                criteria = new AffiliateReportCriteria
                {
                    StartDateUtc        = utcStart,
                    EndDateUtc          = utcEnd,
                    SortBy              = (AffiliateReportCriteria.SortingType)ddlSortBy.SelectedValue.ConvertTo <int>(),
                    SearchBy            = (AffiliateReportCriteria.SearchType)ddlSearchBy.SelectedValue.ConvertTo <int>(),
                    SearchText          = txtSearchText.Text,
                    ShowCommissionOwed  = false,
                    ShowOnlyNonApproved = false
                };
            }

            return(criteria);
        }