public async Task AddCandidatoToTernaAsync(int idRequisicion, int idCandidato, ETerna idTerna)
        {
            var ternas = await this.ternasRepository.ListAsync(new TernasSpecification(idRequisicion))
                         .ConfigureAwait(false);

            var ternaDestino = ternas.FirstOrDefault(t => t?.TipoTerna == idTerna);

            TernaCandidato ternaCandidato = null;

            foreach (var terna in ternas)
            {
                ternaCandidato = terna.TernaCandidato.FirstOrDefault(tc => tc.Id == idCandidato);

                if (ternaCandidato == null)
                {
                    continue;
                }

                ternaCandidato.Ternas          = ternaDestino;
                ternaCandidato.EstadoCandidato = EEstadoCandidato.NoCalificado;
                break;
            }

            if (ternaDestino == null)
            {
                var requisicion = await this.requisicionRepository.Single(new RequisicionSpecification(idRequisicion));

                ternaDestino = new Ternas
                {
                    RequisicionDetalleId = requisicion.RequisicionDetalle.Id,
                    TipoTerna            = idTerna
                };

                await this.ternasRepository.AddAsync(ternaDestino);
            }

            if (ternaCandidato != null)
            {
                if (ternaDestino.TernaCandidato == null)
                {
                    ternaDestino.TernaCandidato = new List <TernaCandidato>();
                }

                ternaDestino.TernaCandidato.Add(ternaCandidato);
                await this.ternasRepository.UpdateAsync(ternaDestino)
                .ConfigureAwait(false);
            }

            await this.AlertarSeguimiento(idRequisicion)
            .ConfigureAwait(false);
        }
Example #2
0
        private async Task AddCandidatoAsync(int idRequisicion, Candidato candidato)
        {
            var entrevistas = await this.candidatoService.GetEntrevistasAsync(idRequisicion).ConfigureAwait(false);

            foreach (var entrevista in entrevistas)
            {
                entrevista.CandidatoId = candidato.Id;
            }

            candidato = this.candidatoService.Single(new CandidatoSpecification(candidato.Id));
            candidato.CandidatoDetalle.StatusCapturaInformacion = EStatusCapturaCandidato.NotificarCapturaInicial;

            await this.candidatoService.UpdateAsync(candidato.Id, candidato).ConfigureAwait(false);

            if (candidato != null)
            {
                var ternaCandidato = new TernaCandidato {
                    CandidatoId = candidato.Id, Entrevistas = entrevistas
                };

                var terna = await this.AddTernaCandidatoAsync(idRequisicion).ConfigureAwait(false);

                if (terna.TernaCandidato != null)
                {
                    terna.TernaCandidato.Add(ternaCandidato);
                }
                else
                {
                    terna.TernaCandidato = new List <TernaCandidato> {
                        ternaCandidato
                    };
                }

                await this.ternasRepository.UpdateAsync(terna).ConfigureAwait(false);

                await this.candidatoService.AlertarSeguimiento(idRequisicion).ConfigureAwait(true);
            }
        }