private static AgendarSegundaEntrevistaViewModel ConvertToAgendarSegundaEntrevistaViewModel(this Entrevista entrevista) { var agendarSegundaEntrevistaViewModel = new AgendarSegundaEntrevistaViewModel() { AgendarSegundaEntrevista = new AgendarSegundaEntrevista() { CandidaturaId = entrevista.CandidaturaId, EntrevistadorId = entrevista.EntrevistadorId, FechaEntrevista = entrevista.FechaEntrevista, Presencial = entrevista.Presencial, AvisarAlCandidato = entrevista.AvisarAlCandidato, EntrevistadorName = entrevista.Entrevistador == null ? string.Empty : entrevista.Entrevistador.Nombre, OficinaId = entrevista.OficinaId, PlantillaCorreoNombre = entrevista.OficinaId == null ? "Genérica" : entrevista.Oficina?.Nombre, NombreCandidato = entrevista.Candidatura.Candidato.Nombre + " " + entrevista.Candidatura.Candidato.Apellidos } }; int nSubEntrevistas = Convert.ToInt16(ConfigurationManager.AppSettings["numeroMaximoSubEntrevistas"].ToString()); var listaSubEntrevistas = entrevista.SubEntrevista.Where(y => y.IsActivo).Select(x => CandidaturaSubEntrevistaMapper.ConvertToSubEntrevistaViewModel(x)).ToList(); var numeroDeSubEntrevistas = listaSubEntrevistas.Count; if (numeroDeSubEntrevistas < nSubEntrevistas) { for (var i = 1; i <= nSubEntrevistas - numeroDeSubEntrevistas; i++) { var subEntrevistaVacia = new SubEntrevistaViewModel(); listaSubEntrevistas.Add(subEntrevistaVacia); } } agendarSegundaEntrevistaViewModel.SubEntrevistaList = listaSubEntrevistas; return(agendarSegundaEntrevistaViewModel); }
public static void UpdateCandidaturaSegundaEntrevista(this Entrevista entrevista, AgendarSegundaEntrevistaViewModel agendarSegundaEntrevistaViewModel, int?entrevistaId) { if (entrevistaId != null) { entrevista.EntrevistaId = (int)entrevistaId; entrevista.ModifiedBy = ModifiableEntityHelper.GetCurrentUser(); entrevista.Modified = ModifiableEntityHelper.GetCurrentDate(); } else { entrevista.CreatedBy = ModifiableEntityHelper.GetCurrentUser(); entrevista.Created = ModifiableEntityHelper.GetCurrentDate(); } if (agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.EntrevistadorId > 0) { entrevista.EntrevistadorId = agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.EntrevistadorId; } entrevista.FechaEntrevista = (DateTime)agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.FechaEntrevista; entrevista.Presencial = agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.Presencial; entrevista.AvisarAlCandidato = agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.AvisarAlCandidato; entrevista.CandidaturaId = agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.CandidaturaId; entrevista.TipoEntrevistaId = (int)TipoEntrevistaEnum.SegundaEntrevista; entrevista.OficinaId = agendarSegundaEntrevistaViewModel.AgendarSegundaEntrevista.OficinaId; entrevista.IsActivo = true; }