public async Task <ActionResult <Guid> > Create(
            [FromBody] CreateCandidateCommand createCandidateCommand)
        {
            var id = await _mediator.Send(createCandidateCommand);

            return(Ok(id));
        }
Example #2
0
        public HttpResponseMessage Post([FromBody] Candidate candidate)
        {
            var response = new HttpResponseMessage();
            var command  = new CreateCandidateCommand(candidate);
            var result   = _commandHander.Handler(command);

            if (result.IsSuccess)
            {
                response = Request.CreateResponse <Candidate>(HttpStatusCode.Created, result.Value);
                response.Headers.Location = new Uri(Request.RequestUri, "/Api/BODCandidateDS/" + result.Value);
            }
            else
            {
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, result.Error);
            }
            return(response);
        }
Example #3
0
        public async Task <IActionResult> Apply([FromBody] CreateCandidateCommand createCandidateCommand,
                                                [FromRoute] string id)
        {
            createCandidateCommand.OfferId = id;
            var candidate = await mediator.Send(createCandidateCommand);

            if (!candidate)
            {
                return(BadRequest(new ApiResponse
                {
                    Success = false,
                    Errors = new[] { "An error occurr when try apply." }
                }));
            }

            return(CreatedAtRoute("GetOfferById", new { id },
                                  new ApiResponse
            {
                Success = true,
                SuccessMessage = "Thanks for apply for this offer."
            }));
        }
Example #4
0
        public async Task <ActionResult <int> > Create([FromBody] CreateCandidateCommand command)
        {
            var candidateId = await Mediator.Send(command);

            return(Ok(candidateId));
        }
Example #5
0
        public async Task <IActionResult> CreateCandidate([FromBody] CreateCandidateCommand command)
        {
            var candidateCreated = await _mediator.Send(command);

            return(CreatedAtRoute("GetCandidate", new { candidateCreated.Id }, candidateCreated));
        }