Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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."));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(CreateApplicantCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }