コード例 #1
0
ファイル: CampaignsTest.cs プロジェクト: naeemsarfraz/GiveCRM
 public void InsertCampaign()
 {
     var campaigns = new Campaigns();
     var campaign = new Campaign
                        {
                            Name = "Test",
                            Description = "Test"
                        };
     campaign = campaigns.Insert(campaign);
     Assert.AreNotEqual(0, campaign.Id);
     Assert.AreEqual("N", campaign.IsClosed);
 }
コード例 #2
0
        public DonationsGenerator(Campaign campaign, ICollection<Member> members)
        {
            if (campaign == null)
            {
                throw new ArgumentException("campaign");
            }

            if (members == null)
            {
                throw new ArgumentException("members");
            }

            this.campaign = campaign;
            this.members = members;

            // donation rate is set somewhere between 1/3 and 2/3
            donationRate = 33 + random.Next(33);
        }
コード例 #3
0
        private Campaign GenerateCampaign()
        {
            string campaignName = string.Format("{0} {1}", random.PickFromList(FemaleNames.Data), random.PickFromList(CampaignNames.CampaignSuffix));

            // close 10% of campaigns
            bool isClosed = random.Percent(10);

            // run (commit) 50% of campaigns, but all of the ones that are closed
            DateTime? runOn = isClosed || random.Percent(50) ? DateTime.Today : (DateTime?) null;

            var campaign = new Campaign
                               {
                                           Name = campaignName,
                                           Description = "A test campaign",
                                           IsClosed = isClosed  ? "Y" : "N",
                                           RunOn = runOn
                               };
            return campaign;
        }
コード例 #4
0
        private void GenerateCampaignDonationsForMember(Donations donationsRepo, Campaign campaign, Member member)
        {
            int numberOfDonations = random.NextInt(0, 3);

            for (int i = 0; i < numberOfDonations; i++)
            {
                // don't generate donations each time to simulate a miss
                if (this.random.Percent(donationRate))
                {
                    decimal amount = GenerateAmount();
                    Donation donation = new Donation
                            {
                                CampaignId = campaign.Id,
                                MemberId = member.Id,
                                Amount = amount,
                                Date = random.NextDateTime(),
                            };
                    donationsRepo.Insert(donation);
                }
            }
        }
コード例 #5
0
 private static ICampaignRepository GetCampaignRepositoryForInsert(Campaign insertedCampaign, Campaign expectedCampaign)
 {
     var campaignRepository = Substitute.For<ICampaignRepository>();
     campaignRepository.Insert(insertedCampaign).Returns(expectedCampaign);
     return campaignRepository;
 }
コード例 #6
0
 private static ICampaignRepository GetCampaignRepositoryForGetById(Campaign expectedCampaign)
 {
     var campaignRepository = Substitute.For<ICampaignRepository>();
     campaignRepository.GetById(4).Returns(expectedCampaign);
     return campaignRepository;
 }
コード例 #7
0
        public void Insert_ShouldReturnTheInsertedCampaignWithANewId()
        {
            const int expectedCampaignId = 20;
            var insertedCampaign = new Campaign { Name = "Test Campaign", IsClosed = "N" };
            var expectedCampaign = new Campaign { Id = expectedCampaignId, Name = "Test Campaign", IsClosed = "N" };

            var campaignRepository = GetCampaignRepositoryForInsert(insertedCampaign, expectedCampaign);
            var campaignService = GetCampaignService(campaignRepository);

            Campaign actualCampaign = campaignService.Insert(insertedCampaign);

            Assert.AreEqual(expectedCampaignId, actualCampaign.Id);
        }
コード例 #8
0
 public void Update(Campaign campaign)
 {
     campaignsDb.Update(campaign);
 }
コード例 #9
0
 public Campaign Insert(Campaign campaign)
 {
     return campaignsDb.Insert(campaign);
 }
コード例 #10
0
ファイル: Campaigns.cs プロジェクト: tombuildsstuff/GiveCRM
 public void Update(Campaign campaign)
 {
     db.Campaigns.UpdateById(campaign);
 }
コード例 #11
0
        public ActionResult Clone(int id)
        {
            var campaign = this.campaignService.Get(id);
            var campaignClone = new Campaign
                                         {
                                             Id = 0,
                                             Description = campaign.Description,
                                             IsClosed = "N",
                                             Name = campaign.Name + " (" + Resources.Literal_Cloned + ")",
                                             RunOn = null
                                         };

            campaignClone = this.campaignService.Insert(campaignClone);

            IEnumerable<MemberSearchFilter> memberSearchFilters = this.memberSearchFilterService.ForCampaign(id);

            foreach (MemberSearchFilter memberSearchFilter in memberSearchFilters)
            {
                this.memberSearchFilterService.Insert(new MemberSearchFilter
                                                  {
                                                      CampaignId = campaignClone.Id,
                                                      DisplayName = memberSearchFilter.DisplayName,
                                                      FilterType = memberSearchFilter.FilterType,
                                                      InternalName = memberSearchFilter.InternalName,
                                                      SearchOperator = memberSearchFilter.SearchOperator,
                                                      Value = memberSearchFilter.Value
                                                  });
            }

            return RedirectToAction("Show", new { id = campaignClone.Id });
        }
コード例 #12
0
 private int InsertCampaign(Campaign campaign)
 {
     var savedCampaign = this.campaignService.Insert(campaign);
     return savedCampaign.Id;
 }
コード例 #13
0
 public ActionResult Create(Campaign campaign)
 {
     var newId = this.InsertCampaign(campaign);
     return RedirectToAction("Show", new { id = newId });
 }
コード例 #14
0
ファイル: Campaigns.cs プロジェクト: nbarnwell/GiveCRM
 public void Update(Campaign campaign)
 {
     databaseProvider.GetDatabase().Campaigns.UpdateById(campaign);
 }
コード例 #15
0
ファイル: Campaigns.cs プロジェクト: nbarnwell/GiveCRM
 public Campaign Insert(Campaign campaign)
 {
     return databaseProvider.GetDatabase().Campaigns.Insert(campaign);
 }
コード例 #16
0
 public Campaign Insert(Campaign campaign)
 {
     return campaignRepository.Insert(campaign);
 }
コード例 #17
0
 public void Update(Campaign campaign)
 {
     campaignRepository.Update(campaign);
 }
コード例 #18
0
ファイル: Campaigns.cs プロジェクト: tombuildsstuff/GiveCRM
 public Campaign Insert(Campaign campaign)
 {
     return db.Campaigns.Insert(campaign);
 }