public ActionResult OfertaLaboral(Oferta oferta) { TicketEmpresa ticket = (TicketEmpresa)Session["TicketEmpresa"]; var cantidadCarreras = ((List<OfertaEstudio>)(Session["CarrerasSeleccionadas"])).Count; //Se contabilizan la cantidad de carreras seleccionadas. if (ModelState.IsValid && cantidadCarreras > 0) { //oferta.UsuarioPropietarioEmpresa = ""; oferta.ModificadoPor = ticket.Usuario; //12FEB: Si el estado actual es BORRADOR debe cambiar a EN CONSTRUCCION: if (oferta.EstadoOferta == Constantes.OFERTA_ESTADO_BORRADOR) oferta.EstadoOferta = Constantes.OFERTA_ESTADO_ENCONSTRUCCION; //Se actualizan las fase de la oferta: //foreach (var item in oferta.OfertaFases) //{ // //Estos 3 registros siempre están activos. // if (item.IdListaValor == "OFFAPR" || item.IdListaValor == "OFFACV" || item.IdListaValor == "OFFAFI") // { // item.Incluir = true; // } // item.ModificadoPor = ticket.Usuario; //} //Se obtiene los datos de sesión. oferta.CarrerasSeleccionadas = (List<OfertaEstudio>)(Session["CarrerasSeleccionadas"]); //Método general para actualizar la oferta. lnOfertaEmpresa.Actualizar(oferta, ticket.Usuario); //lnOferta.ActualizarOfertaFase(oferta.OfertaFases); //Se guardan los estudios de la oferta. //Primero hay que eliminar los estudios universitarios. //LNOfertaEstudio lnOfertaEstudio = new LNOfertaEstudio(); //foreach (var ofertaEstudioUTP in oferta.CarrerasSeleccionadas) //{ // lnOfertaEstudio.Insertar(ofertaEstudioUTP); //} //1. Mostrar mensaje de éxito. TempData["MsjExitoEditarOferta"] = "La oferta '" + oferta.CargoOfrecido + "' ha sido actualizada con éxito."; //2. Redireccionar a la lista. //return RedirectToAction("Publicacion"); } else { var errors = ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList(); int a = 0; } LNGeneral lnGeneral = new LNGeneral(); LNEmpresaLocacion lnEmpresaLocacion = new LNEmpresaLocacion(); ViewBag.TipoCargoIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_TIPO_CARGO), "IdListaValor", "Valor", oferta.TipoCargoIdListaValor); ViewBag.TipoTrabajoIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_TIPO_TRABAJO), "IdListaValor", "Valor", oferta.TipoTrabajoIdListaValor); ViewBag.TipoContratoIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_TIPO_CONTRATO), "IdListaValor", "Valor", oferta.TipoContratoIdListaValor); ViewBag.IdEmpresaLocacion = new SelectList(lnEmpresaLocacion.ObtenerLocaciones(ticket.IdEmpresa), "IdEmpresaLocacion", "NombreLocacion", oferta.IdEmpresaLocacion); ViewBag.RecibeCorreosIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_OFERTA_RECIBECORREOS), "IdListaValor", "Valor", oferta.RecibeCorreosIdListaValor); //Se agrega el estado del estudio para las carreras: ViewBag.EstadoCarreraUTP = new SelectList(lnGeneral.ObtenerListaValorOfertaEstudiosUTP(Constantes.IDLISTA_ESTADO_DEL_ESTUDIO), "IdListaValor", "Valor"); if (cantidadCarreras == 0) { ViewBag.MensajeCarrerasSeleccionadas = "Debe seleccionar al menos una carrera"; TempData["MsjErrorNoCarreras"] = "error"; } else { ViewBag.MensajeCarrerasSeleccionadas = ""; } return View(oferta); }
public ActionResult OfertaLaboral(string id) { string idLegible = Utiles.Helper.Desencriptar(id); int idOferta = Convert.ToInt32(idLegible); TicketEmpresa ticket = (TicketEmpresa)Session["TicketEmpresa"]; Oferta oferta = lnOferta.ObtenerPorId(idOferta); LNGeneral lnGeneral = new LNGeneral(); LNEmpresaLocacion lnEmpresaLocacion = new LNEmpresaLocacion(); //Se cargan los combos: ViewBag.TipoCargoIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_TIPO_CARGO), "IdListaValor", "Valor", oferta.TipoCargoIdListaValor); ViewBag.TipoTrabajoIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_TIPO_TRABAJO), "IdListaValor", "Valor", oferta.TipoTrabajoIdListaValor); ViewBag.TipoContratoIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_TIPO_CONTRATO), "IdListaValor", "Valor", oferta.TipoContratoIdListaValor); ViewBag.IdEmpresaLocacion = new SelectList(lnEmpresaLocacion.ObtenerLocaciones(ticket.IdEmpresa), "IdEmpresaLocacion", "NombreLocacion", oferta.IdEmpresaLocacion); ViewBag.RecibeCorreosIdListaValor = new SelectList(lnGeneral.ObtenerListaValor(Constantes.IDLISTA_OFERTA_RECIBECORREOS), "IdListaValor", "Valor", oferta.RecibeCorreosIdListaValor); //TempData["ListaCarrerasDisponibles"] = new SelectList(oferta.CarrerasDisponibles, "IdListaValor", "Valor"); if (oferta.EstadoOferta == Constantes.OFERTA_ESTADO_BORRADOR) ViewBag.Disabled = "disabled"; else ViewBag.Disabled = ""; //Se agrega el estado del estudio para las carreras: ViewBag.EstadoCarreraUTP = new SelectList(lnGeneral.ObtenerListaValorOfertaEstudiosUTP(Constantes.IDLISTA_ESTADO_DEL_ESTUDIO), "IdListaValor", "Valor"); Session["CarrerasDisponibles"] = oferta.CarrerasDisponibles; Session["CarrerasSeleccionadas"] = oferta.CarrerasSeleccionadas; //Se agrega a sesión las carreras seleccionadas. return View("OfertaLaboral", oferta); }