Example #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));
            }));
        }
Example #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)));
            }
        }
        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 }));
            }
        }
        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"));
            }
        }
Example #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));
        }