Exemple #1
0
        public ActionResult <CampaignDto> CreateCampaign([FromBody] CreateCampaignDto createCampaignDto)
        {
            var newCampaign = _campaignMapper.ToDto(
                _campaignService.AddCampaign(
                    _campaignMapper.ToNewDomain(createCampaignDto)));

            return(Created($"api/campaign/{newCampaign.Id}", newCampaign));
        }
        public void GivenACampaign_WhenToDto_ThenReturnCampaignDtoObjectWithSameProperties()
        {
            //given
            var campaign = new CampaignBuilder()
                                .WithId(Guid.NewGuid())
                                .WithName("testName")
                                .WithClient("testClient")
                                .WithStatus(CampaignStatus.Active)
                                .WithStartDate(DateTime.Today.AddDays(5))
                                .WithClassStartDate(DateTime.Today.AddDays(5))
                                .WithComment("testComment")
                                .Build();

            var campaignMapper = new CampaignMapper();

            //when
            var newDto = campaignMapper.ToDto(campaign);

            //then
            Assert.Equal(campaign.Id.ToString(), newDto.Id);
            Assert.Equal(campaign.Name, newDto.Name);
            Assert.Equal(campaign.Client, newDto.Client);
            Assert.Equal(campaign.Status, newDto.Status);
            Assert.Equal(campaign.StartDate, newDto.StartDate);
            Assert.Equal(campaign.ClassStartDate, newDto.ClassStartDate);
            Assert.Equal(campaign.Comment, newDto.Comment);
        }
        public override JobApplicationDto ToDto(JobApplication domainObject)
        {
            var jobappDto = new JobApplicationDto()
            {
                Id          = domainObject.Id.ToString(),
                CandidateId = domainObject.CandidateId.ToString(),
                CampaignId  = domainObject.CampaignId.ToString(),
                Status      = domainObject.Status.ToString(),
                Candidate   = _candidateMapper.ToDto(domainObject.Candidate),
                Campaign    = _campaignMapper.ToDto(domainObject.Campaign)
            };

            if (domainObject.CurrentSelectionStep != null)
            {
                jobappDto.SelectionSteps       = _selectionStepMapper.ToDtoList(domainObject.SelectionSteps);
                jobappDto.CurrentSelectionStep = _selectionStepMapper.ToDto(domainObject.CurrentSelectionStep);
            }
            return(jobappDto);
        }