Esempio n. 1
0
        public async Task <ActionResult> Put(string username, [FromBody] UpdateApplicantCommand command)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(ModelStateErrorResponseError());
            }

            var applicant = command.ToModel(username);
            await _dummyUserService.Update(applicant);

            return(ResponsePutPatch());
        }
        public UpdateApplicantCommand ToUpdateApplicantCommand(int id)
        {
            var command = new UpdateApplicantCommand();

            command.Id              = id;
            command.Name            = Name;
            command.Family          = Family;
            command.EmailAddress    = EmailAddress;
            command.CountryOfOrigin = CountryOfOrigin;
            command.Age             = Age;
            command.Address         = Address;
            command.Hired           = Hired;
            return(command);
        }
Esempio n. 3
0
        public async Task Handle_GivenInValidRequestId_ShouldThrowNotFoundException()
        {
            // Arrange
            var sut     = new UpdateApplicantCommandQueryHandler(_context);
            var id      = 100;
            var request = new UpdateApplicantCommand {
                ID = id
            };

            // Act


            // Assert
            await Assert.ThrowsAsync <NotFoundException>(() => sut.Handle(request, CancellationToken.None));
        }
        public async Task UpdateApplicant(UpdateApplicantCommand command)
        {
            var applicant = await _applicantRepository.Get(command.Id);

            var modifiedApplicant = Applicant.Instance(applicant, _countryService)
                                    .WithName(command.Name)
                                    .WithFamily(command.Family)
                                    .WithAddress(command.Address)
                                    .WithCountryOfOrigin(command.CountryOfOrigin)
                                    .WithEmailAddress(command.EmailAddress)
                                    .WithAge(command.Age)
                                    .WithHired(command.Hired)
                                    .Build();
            await _applicantRepository.Update(modifiedApplicant);
        }
Esempio n. 5
0
        public async Task <ActionResult> Put(string username, [FromBody] UpdateApplicantCommand model)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(ModelStateErrorResponseError());
            }

            var actual = await _dummyUserService.Find(username).ConfigureAwait(false);

            model.Update(actual);
            await _dummyUserService.Update(actual).ConfigureAwait(false);

            return(ResponsePutPatch());
        }
Esempio n. 6
0
        public async Task <ActionResult> Update([FromBody] UpdateApplicantCommand updateApplicantCommand)
        {
            await _mediator.Send(updateApplicantCommand);

            return(NoContent());
        }
 public async Task <IActionResult> Update([FromBody] UpdateApplicantCommand command)
 {
     return(Ok(await Mediator.Send(command)));
 }