public void Should_Map() { // Arrange var dto = new MyMusicianProfileCreateDto { LevelAssessmentInner = 1, InstrumentId = Guid.NewGuid(), InquiryStatusInnerId = Guid.NewGuid(), }; dto.PreferredPositionsInnerIds.Add(Guid.NewGuid()); dto.DoublingInstruments.Add(new MyDoublingInstrumentCreateDto { AvailabilityId = Guid.NewGuid(), Comment = "Comment", InstrumentId = Guid.NewGuid(), LevelAssessmentInner = 2, }); dto.PreferredPartsInner.Add(4); // Act Create.Command command = _mapper.Map <Create.Command>(dto); // Assert command.Should().BeEquivalentTo(dto); }
public async Task <MyMusicianProfileDto> CreateMusicianProfileAsync(MyMusicianProfileCreateDto createDto) { Domain.Logic.MusicianProfiles.Create.Command command = _mapper.Map <Domain.Logic.MusicianProfiles.Create.Command>(createDto); command.PersonId = _userAccessor.PersonId; MusicianProfile createdEntity = await _mediator.Send(command); return(_mapper.Map <MyMusicianProfileDto>(createdEntity)); }
public async Task Should_Add_My_MusicianProfile() { // Arrange var createDto = new MyMusicianProfileCreateDto { InstrumentId = SectionSeedData.Clarinet.Id, LevelAssessmentInner = 1, }; createDto.PreferredPositionsInnerIds.Add(SelectValueSectionSeedData.ClarinetCoach.Id); createDto.PreferredPartsInner.Add(2); createDto.PreferredPartsInner.Add(4); var createDoublingInstrumentDto = new MyDoublingInstrumentCreateDto { InstrumentId = SectionSeedData.EbClarinet.Id, AvailabilityId = SelectValueMappingSeedData.MusicianProfileSectionInstrumentAvailabilityMappings[0].Id, LevelAssessmentInner = 4, Comment = "my comment" }; createDto.DoublingInstruments.Add(createDoublingInstrumentDto); var expectedDto = new MyMusicianProfileDto { InstrumentId = createDto.InstrumentId, LevelAssessmentInner = createDto.LevelAssessmentInner, CreatedBy = _performer.DisplayName, CreatedAt = FakeDateTime.UtcNow, PersonId = _performer.PersonId }; expectedDto.PreferredPositionsInnerIds.Add(SelectValueSectionSeedData.ClarinetCoach.Id); expectedDto.PreferredPartsInner.Add(2); expectedDto.PreferredPartsInner.Add(4); expectedDto.DoublingInstruments.Add(new MyDoublingInstrumentDto { AvailabilityId = createDoublingInstrumentDto.AvailabilityId, Comment = createDoublingInstrumentDto.Comment, InstrumentId = createDoublingInstrumentDto.InstrumentId, CreatedAt = FakeDateTime.UtcNow, CreatedBy = _performer.DisplayName, LevelAssessmentInner = createDoublingInstrumentDto.LevelAssessmentInner }); // Act HttpResponseMessage responseMessage = await _authenticatedServer .CreateClient() .AuthenticateWith(_performer) .PostAsync(ApiEndpoints.MyMusicianProfilesController.Post(), BuildStringContent(createDto)); // Assert responseMessage.StatusCode.Should().Be(HttpStatusCode.Created); MyMusicianProfileDto result = await DeserializeResponseMessageAsync <MyMusicianProfileDto>(responseMessage); result.Should().BeEquivalentTo(expectedDto, opt => opt.Excluding(r => r.Id).Excluding(r => r.DoublingInstruments)); result.Id.Should().NotBeEmpty(); result.DoublingInstruments.Count.Should().Be(1); result.DoublingInstruments.First().Should().BeEquivalentTo(expectedDto.DoublingInstruments.First(), opt => opt.Excluding(dto => dto.Id)); result.DoublingInstruments.First().Id.Should().NotBeEmpty(); responseMessage.Headers.Location.AbsolutePath.Should().Be($"/{ApiEndpoints.MusicianProfilesController.Get(result.Id)}"); }
public async Task <ActionResult <MyMusicianProfileDto> > Post([FromBody] MyMusicianProfileCreateDto myMusicianProfileCreateDto) { MyMusicianProfileDto createdMusicianProfile = await _meService.CreateMusicianProfileAsync(myMusicianProfileCreateDto); return(CreatedAtAction(nameof(MusicianProfilesController.GetById), "MusicianProfiles", new { id = createdMusicianProfile.Id }, createdMusicianProfile)); }