Exemplo n.º 1
0
        public async Task Update_ShouldUpdateParticipant()
        {
            // Arrange
            var options = BuildContextOptions();

            Participant participant;

            using (var context = new BorrowBuddyContext(options)) {
                participant = context.AddParticipant();
                context.SaveChanges();
            }

            // Act
            using (var context = new BorrowBuddyContext(options)) {
                var service = new ParticipantService(context);

                await service.UpdateAsync(participant.Id, new ParticipantDto {
                    FirstName  = "FirstName_Modified",
                    LastName   = "LastName_Modified",
                    MiddleName = "MiddleName_Modified"
                });
            }

            // Assert
            using (var context = new BorrowBuddyContext(options)) {
                var result = context.Participants.FirstOrDefault();
                Assert.NotNull(result);
                Assert.Equal("FirstName_Modified", result.FirstName);
                Assert.Equal("LastName_Modified", result.LastName);
                Assert.Equal("MiddleName_Modified", result.MiddleName);
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutParticipant([FromRoute] Guid id, [FromBody] Participant model)
        {
            if (model.Id != id)
            {
                return(BadRequest());
            }

            if (!await ParticipantExistsAsync(id))
            {
                return(NotFound());
            }

            var flow = await _participantService.UpdateAsync(id,
                                                             new ParticipantDto {
                FirstName  = model.FirstName,
                LastName   = model.LastName,
                MiddleName = model.MiddleName
            });

            return(NoContent());
        }