Exemple #1
0
        public void Save_Candidate_Required()
        {
            var election = new Election();
            var campaign = new CandidateCampaign
            {
                Election = election,
            };

            context.CandidateCampaigns.Add(campaign);
            Assert.Throws <DbUpdateException>(() => context.SaveChanges());
        }
Exemple #2
0
        public void Save_Election_Required()
        {
            var candidate = new Candidate {
                Name = "Test Candidate"
            };
            var campaign = new CandidateCampaign
            {
                Candidate = candidate
            };

            context.CandidateCampaigns.Add(campaign);
            Assert.Throws <DbUpdateException>(() => context.SaveChanges());
        }
Exemple #3
0
        public void Save_Party_NotRequired()
        {
            var election  = new Election();
            var candidate = new Candidate {
                Name = "Test Candidate"
            };
            var campaign = new CandidateCampaign
            {
                Candidate = candidate,
                Election  = election,
            };

            context.CandidateCampaigns.Add(campaign);
            context.SaveChanges();
        }
Exemple #4
0
 public string AddCandidat(int idCampaign, int idCandidat, int idGroup)
 {
     try
     {
         var ca = new CandidateCampaign {
             IdCampaign = idCampaign, IdCandidate = idCandidat, IdGroup = idGroup
         };
         db.CandidateCampaigns.Add(ca);
         db.SaveChanges();
         return("success");
     }
     catch (Exception e)
     {
         return("error");
     }
 }