public bool Insertar(PasantiasPreProfesionales item, out int?id) { bool result = false; int? auxId = 0; string strUrl = Properties.UdlaListDefinitions.Default.Url_Sitio; try { if (SPContext.Current != null) { HttpContext.Current = null; } SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSite = new SPSite(strUrl)) { using (SPWeb oWeb = oSite.OpenWeb()) { HttpRequest httpRequest = new HttpRequest("", oWeb.Url, ""); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new System.IO.StringWriter())); SPControl.SetContextWeb(HttpContext.Current, oWeb); using (UdlaEntityDataContext context = new UdlaEntityDataContext(oWeb.Url)) { EntityList <ListaPasantiasElemento> pasantias = context.GetList <ListaPasantiasElemento>(Properties.UdlaListDefinitions.Default.Lista_Pasantias); var itemBase = MappeoMoss(item); pasantias.InsertOnSubmit(itemBase); context.SubmitChanges(); itemBase.Accion = string.Format(itemBase.Accion, itemBase.Identificador); itemBase.Título = string.Format(itemBase.Título, itemBase.Identificador); context.SubmitChanges(); auxId = itemBase.Identificador; result = true; } } } } ); } catch (Exception ex) { auxId = 0; Logger.ExLogger(ex); throw ex; } id = auxId; return(result); }
public bool Insertar(Actividades item, out int?id) { bool result = false; int? auxId = 0; string strUrl = Properties.UdlaListDefinitions.Default.Url_Sitio; try { if (SPContext.Current != null) { HttpContext.Current = null; } SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSite = new SPSite(strUrl)) { using (SPWeb oWeb = oSite.OpenWeb()) { HttpRequest httpRequest = new HttpRequest("", oWeb.Url, ""); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new System.IO.StringWriter())); SPControl.SetContextWeb(HttpContext.Current, oWeb); using (UdlaEntityDataContext context = new UdlaEntityDataContext(oWeb.Url)) { EntityList <ListaDeActividadesPorEstudianteElemento> actividades = context.GetList <ListaDeActividadesPorEstudianteElemento>(Properties.UdlaListDefinitions.Default.Lista_Actividades); var itemBase = MappeoMoss(item); itemBase.Identificador = null; itemBase.IdPasantia = context.ListaPasantias.Where(x => x.Identificador == item.idPasantia).Take(1).ToList().First(); actividades.InsertOnSubmit(itemBase); context.SubmitChanges(); auxId = itemBase.Identificador; result = true; } } } } ); } catch (Exception ex) { auxId = 0; Logger.ExLogger(ex); throw ex; } id = auxId; return(result); }
public PasantiasPreProfesionales Actualizar(PasantiasPreProfesionales item) { string strUrl = Properties.UdlaListDefinitions.Default.Url_Sitio; ListaPasantiasElemento pasantiasBase = null; PasantiasPreProfesionales pasantiaFinal = null; HttpContext backupCtxt = HttpContext.Current; try { if (SPContext.Current != null) { HttpContext.Current = null; } SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSite = new SPSite(strUrl)) { using (SPWeb oWeb = oSite.OpenWeb()) { HttpRequest httpRequest = new HttpRequest("", oWeb.Url, ""); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new System.IO.StringWriter())); SPControl.SetContextWeb(HttpContext.Current, oWeb); using (UdlaEntityDataContext context = new UdlaEntityDataContext(oWeb.Url)) { EntityList <ListaPasantiasElemento> pasantias = context.GetList <ListaPasantiasElemento>(Properties.UdlaListDefinitions.Default.Lista_Pasantias); pasantiasBase = pasantias.Where(x => x.Identificador == item.Id).Take(1).ToList().First();; if (pasantiasBase != null) { pasantiasBase = MappeoMoss(item, pasantiasBase); context.SubmitChanges(); pasantiaFinal = MappeoMoss(pasantiasBase); } } } } } ); } catch (Exception ex) { Logger.ExLogger(ex); throw ex; } return(pasantiaFinal); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="estado"></param> /// <param name="esSeleccionado"></param> /// <returns></returns> public bool CambiarEstadoSeleccionadoAlumnoDocente(int id, string estado, bool esSeleccionado) { string strUrl = Properties.UdlaListDefinitions.Default.Url_Sitio; bool val = false; HttpContext backupCtxt = HttpContext.Current; try { if (SPContext.Current != null) { HttpContext.Current = null; } SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSite = new SPSite(strUrl)) { using (SPWeb oWeb = oSite.OpenWeb()) { HttpRequest httpRequest = new HttpRequest("", oWeb.Url, ""); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new System.IO.StringWriter())); SPControl.SetContextWeb(HttpContext.Current, oWeb); using (UdlaEntityDataContext context = new UdlaEntityDataContext(oWeb.Url)) { var pasantiasBase = context.ListaPasantias.Where(x => x.Identificador == id).Take(1).ToList().First();; if (pasantiasBase != null) { pasantiasBase.EsSeleccionadoPorDocente = esSeleccionado; pasantiasBase.EsSeleccionado = esSeleccionado; pasantiasBase.Estado = estado; context.SubmitChanges(); val = true; } } } } } ); } catch (Exception ex) { Logger.ExLogger(ex); throw ex; } return(val); }
public Visitas Actualizar(Visitas item) { Visitas visita = null; string strUrl = Properties.UdlaListDefinitions.Default.Url_Sitio; try { if (SPContext.Current != null) { HttpContext.Current = null; } SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSite = new SPSite(strUrl)) { using (SPWeb oWeb = oSite.OpenWeb()) { HttpRequest httpRequest = new HttpRequest("", oWeb.Url, ""); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new System.IO.StringWriter())); SPControl.SetContextWeb(HttpContext.Current, oWeb); using (UdlaEntityDataContext context = new UdlaEntityDataContext(oWeb.Url)) { EntityList <ListaVisitasElemento> visitas = context.GetList <ListaVisitasElemento>(Properties.UdlaListDefinitions.Default.Lista_Visitas); var visitaBase = visitas.Where(x => x.Identificador == item.Id).Take(1).ToList().First();; if (visitaBase != null) { visitaBase = MappeoMoss(item, visitaBase); context.SubmitChanges(); visita = MappeoMoss(visitaBase); } } } } } ); } catch (Exception ex) { Logger.ExLogger(ex); throw ex; } return(visita); }