コード例 #1
0
        public IActionResult Post([FromBody] CreateCandidateViewModel vm)
        {
            return(ApiAction(() =>
            {
                var contract = _mapper.Map <CreateCandidateContract>(vm);
                var returnContract = _candidateService.Create(contract);

                return Created("Get", _mapper.Map <CreatedCandidateViewModel>(returnContract));
            }));
        }
コード例 #2
0
        public IActionResult Create([FromBody] CandidateCreateUpdateDto model)
        {
            try
            {
                _candidateService.Create(model);

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.BadRequest, new ErrorResponse(ex)));
            }
        }
コード例 #3
0
        public IActionResult Register([FromBody] DCandidate model)
        {
            // map model to entity
            var candidate = _mapper.Map <Candidate>(model);

            try
            {
                // create candidate
                _candidateService.Create(candidate);
                return(Ok());
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
コード例 #4
0
        public async Task <ActionResult <Candidate> > PostCandidate(Candidate candidate)
        {
            try
            {
                if (candidate == null)
                {
                    return(BadRequest());
                }

                var createdCandidate = await _candidateService.Create(candidate);

                return(CreatedAtAction(nameof(GetCandidate),
                                       new { id = createdCandidate.CandidateId }, createdCandidate));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error creating new candidate record"));
            }
        }
コード例 #5
0
 public Candidate Create([FromBody] CreateCandidateDto candidate)
 {
     return(_candidateService.Create(candidate));
 }
        public async Task <ActionResult <CandidateDto> > Create(CandidateDtoWithoutId objectToCreate)
        {
            var created = await _candidateService.Create(_candidateMapper.DtoToDomain(objectToCreate));

            return(_candidateMapper.DomainToDto(created));
        }