public void Save_Candidate_Required() { var election = new Election(); var campaign = new CandidateCampaign { Election = election, }; context.CandidateCampaigns.Add(campaign); Assert.Throws <DbUpdateException>(() => context.SaveChanges()); }
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()); }
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(); }
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"); } }