public List <Candidate> Add(Candidate c)
        {
            var repo = new CandidateRepository(_connectionString);

            repo.Add(c);
            return(repo.GetAll());
        }
        public List <Candidate> Refuse(CandidateViewModel vm)
        {
            var repo = new CandidateRepository(_connectionString);

            repo.RefuseCandidate(vm.CandidateId);
            return(repo.GetAll());
        }
Example #3
0
        //
        // GET: api/Candidate/

        public Candidate[] Get(string databaseId)
        {
            CandidateRepository candidateRepository;

            candidateRepository = new CandidateRepository(databaseId);
            return(candidateRepository.GetAll().Values.ToArray());
        }
        public void GivenExistingCandidates_WhenGetAll_ThenReturnAllCandidates()
        {
            using (var context = new SwintakeContext(_options))
            {
                var guidId  = Guid.NewGuid();
                var janneke = new CandidateBuilder()
                              .WithId(guidId)
                              .WithFirstName("Janneke")
                              .WithLastName("Janssens")
                              .WithEmail("*****@*****.**")
                              .WithPhoneNumber("0470000000")
                              .WithGitHubUsername("janneke")
                              .WithLinkedIn("janneke")
                              .Build();

                IRepository <Candidate> candidateRepository = new CandidateRepository(context);

                //when
                candidateRepository.Save(janneke);
                IList <Candidate> searchCandidate = candidateRepository.GetAll();

                //then
                Assert.Equal(1, searchCandidate.Count);
            }
        }
        /// <summary>
        /// Get all candidates having an interview no longer then a moth ago
        /// </summary>
        /// <returns></returns>
        public IEnumerable <CandidateGetDTO> GetAll()
        {
            var      candidateEntities        = CandidateRepository.GetAll();
            DateTime monthAgo                 = DateTime.Today.AddMonths(-1);
            var      currentcandidateEntities = candidateEntities.OrderBy(candidate => candidate.InterviewBeginsAt > monthAgo);
            var      candidateDTOs            = AMapper.Mapper.Map <IEnumerable <Candidate>, IEnumerable <CandidateGetDTO> >(currentcandidateEntities);

            return(candidateDTOs);
        }
Example #6
0
        public VoteViewModel()
        {
            var candidateRepository = new CandidateRepository();
            var candidate           = candidateRepository.GetAll();

            if (candidate != null)
            {
                Candidates = new ObservableCollection <Candidate>(candidate);
            }
        }
Example #7
0
 public ActionResult <IEnumerable <Candidate> > GetAllCandidate()
 {
     try
     {
         var candidates = _repositoryCandidate.GetAll();
         return(Ok(candidates));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(BadRequest(ex.Message));
     }
 }
Example #8
0
        public void Given_CandidateRepo_When_GetAllIsCalled_Then_CountIs0()
        {
            RunOnDatabase(async context =>
            {
                //Arrange
                var candidateRepo = new CandidateRepository(context, _loggerFactory);

                //Act
                var res = await candidateRepo.GetAll();

                //Assert
                res.Count.Should().Be(0);
            });
        }
        public void SimpeDeHydrateAll_Candidate()
        {
            IRaceRepository           raceRepository           = Substitute.For <IRaceRepository>();
            IPoliticalPartyRepository politicalPartyRepository = Substitute.For <IPoliticalPartyRepository>();
            var f              = new Fixture();
            var race           = f.Create <Race>();
            var politicalParty = f.Create <PoliticalParty>();
            var candidate      = Create();

            raceRepository.GetById(Arg.Any <Guid>()).Returns(race);
            politicalPartyRepository.GetById(Arg.Any <Guid>()).Returns(politicalParty);
            var candidateRepository = new CandidateRepository(ContextConnection(), politicalPartyRepository, raceRepository);

            candidateRepository.Save(candidate);
            var owner = candidateRepository.GetAll();

            Assert.That(owner.Any());
        }
 public HttpResponseMessage Get()
 {
     try
     {
         CandidateRepository     rep  = new CandidateRepository();
         IEnumerable <Candidate> list = Mapper.ToList <Candidate>(rep.GetAll());
         if (list != null && list.Count() > 0)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, list));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.NoContent));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Example #11
0
 public async Task <List <Candidate> > GetAll()
 {
     _loggerManager.LogInfo("getting list of candidates from repository");
     return(await _candidateRepository.GetAll());
 }
        public List <Candidate> GetAll(string status)
        {
            var repo = new CandidateRepository(_connectionString);

            return(repo.GetAll(status));
        }