Exemple #1
0
        public SaveBecarioResponse SaveBecario(BecarioDatosBasicosViewModel becarioDatosBasicosViewModel, bool changeEtapa)
        {
            var response = new SaveBecarioResponse()
            {
                IsValid = true
            };

            try
            {
                var becario     = new Becario();
                var candidatura = _candidaturaRepository.GetOne(x => x.CandidatoId == becarioDatosBasicosViewModel.CandidatoId);

                if (becarioDatosBasicosViewModel.BecarioId.HasValue)
                {
                    becario = _becarioRepository.GetOne(x => x.BecarioId == becarioDatosBasicosViewModel.BecarioId.Value);
                }

                becario.UpdateBecario(becarioDatosBasicosViewModel);

                //Actualizamos la candidatura asociada si existiese
                if (candidatura != null)
                {
                    candidatura.OrigenCvId            = becario.OrigenCvId;
                    candidatura.FuenteReclutamientoId = becario.FuenteReclutamientoId;
                    candidatura.EmailsReferenciados   = becario.EmailsReferenciados;
                    _candidaturaRepository.Update(candidatura);
                }

                //Actualizamos o creamos becario
                if (becario.BecarioId > 0)
                {
                    _becarioRepository.Update(becario);
                }
                else
                {
                    becario.UrlCV = becarioDatosBasicosViewModel.UrlCV;
                    becario       = _becarioRepository.Create(becario);
                    _bitacoraBecarioService.GenerateBitacoraCreateBecario(becario.BecarioId);
                }

                response.BecarioId = becario.BecarioId;
                response.NombreCV  = becario.NombreCV;
            }
            catch (Exception ex)
            {
                response.IsValid      = false;
                response.ErrorMessage = ex.Message;
            }

            return(response);
        }