public CreateApplicantCommand ToCreateApplicantCommand() { var command = new CreateApplicantCommand(); command.Name = Name; command.Family = Family; command.EmailAddress = EmailAddress; command.CountryOfOrigin = CountryOfOrigin; command.Age = Age; command.Address = Address; command.Hired = Hired; return(command); }
public async Task <int> CreateApplicant(CreateApplicantCommand command) { var applicant = new Applicant.ApplicantBuilder(_countryService) .WithName(command.Name) .WithFamily(command.Family) .WithAddress(command.Address) .WithCountryOfOrigin(command.CountryOfOrigin) .WithEmailAddress(command.EmailAddress) .WithAge(command.Age) .WithHired(command.Hired) .Build(); return(await _applicantRepository.Add(applicant)); }
public async Task <ActionResult <CreateApplicantCommandResponse> > Create([FromBody] CreateApplicantCommand createApplicantCommand) { try { var response = await _mediator.Send(createApplicantCommand); if (!response.Success) { return(response); } var location = _linkGenerator.GetPathByAction("GetApplicantById", "Applicants", new { response.Applicant.Id }); if (string.IsNullOrWhiteSpace(location)) { return(BadRequest("Could not use current applicant.")); } return(Created(location, response)); } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "DAtabase failed to create new applicant.")); } }
public async Task <IActionResult> Create(CreateApplicantCommand command) { await Mediator.Send(command); return(NoContent()); }