Beispiel #1
0
 void ICandidatesCommand.CreateCandidate(Candidate candidate)
 {
     candidate.LastUpdatedTime = DateTime.Now;
     candidate.Prepare();
     candidate.Validate();
     _repository.CreateCandidate(candidate);
 }
        // POST: api/Candidates
        public ResponseModel Post([FromBody] CandidateModel Candidate)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ResponseModel Response = _ICandidatesRepository.CreateCandidate(Candidate);

                    if (Response.ID > 0)
                    {
                        return(Response);
                    }
                    else
                    {
                        return(Helpers.ResponseFactory.Create(false));
                    }
                }
                else
                {
                    ResponseModel ErrorResponse = Helpers.ResponseFactory.Create(false);
                    ErrorResponse.Message = "Candidate information is incorrect. Please take a look at the details.";
                    ErrorResponse.Object  = ModelState.Values.SelectMany(v => v.Errors);
                    return(ErrorResponse);
                }
            }
            catch (Exception ex)
            {
                Helpers.Utils.RegisterException("Candidates: Post", ex.Message);
                return(Helpers.ResponseFactory.Create(false));
            }
        }