Exemplo n.º 1
0
        public async Task <IActionResult> UpdateCandidate([FromBody] UpdateCandidateCommand command, Guid id)
        {
            command.Id = id;
            var candidateUpdated = await _mediator.Send(command);

            return(Ok(candidateUpdated));
        }
Exemplo n.º 2
0
        public HttpResponseMessage Put([FromBody] Candidate candidate)
        {
            var response = new HttpResponseMessage();
            var cmd      = new UpdateCandidateCommand(candidate);
            var result   = _commandHander.Handler(cmd);

            if (result.IsSuccess)
            {
                response = Request.CreateResponse <Candidate>(HttpStatusCode.OK, candidate);
            }
            else
            {
                response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, result.Error);
            }
            return(response);
        }
        public async Task <IActionResult> Update(Guid id, CandidateModifyModel model)
        {
            if (ModelState.IsValid)
            {
                var cmd    = new UpdateCandidateCommand(model.Id, model.FirstName, model.LastName, model.Birthday, model.CurrentPosition, model.Note);
                var result = await _mediator.Send(cmd);

                if (result.IsFailure)
                {
                    ModelState.AddModelError("", result.Error);
                }
                else
                {
                    return(RedirectToAction(nameof(CandidateController.Index)));
                }
            }

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Update([FromBody] UpdateCandidateCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }