/// <summary> /// Metodo utilizado para devolver todos los Socio /// SELECT * FROM Socio /// </summary> /// <returns></returns> public List <Socio> devolverTodos(string search) { try { using (var db = new ModeloRenacer()) { //if (search != null) // return db.socio.Where(x => x.fechaBaja == null && x.nombre.Contains(@search)).ToList(); //return db.socio.Where(x => x.nombre.Contains(@search)).Skip(page * limit).Take(limit).ToList(); //else return(db.socio.Where(x => x.fechaBaja == null && x.nombre.Contains(@search)).ToList()); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } return(null); }
/// <summary> /// Metodo utilizado para Insertar un nuevo espacioComun. /// </summary> /// <param name="espacioComun"></param> public void grabar(EspacioComun espacioComun) { try { var errores = this.validar(espacioComun); if (errores.Count > 0) { throw new UsuarioException(errores); } if (espacioComun.id == 0) { espacioComun.fechaCreacion = DateTime.Now; } if (espacioComun.id > 0) { espacioComun.fechaModificacion = DateTime.Now; } using (var db = new ModeloRenacer()) { Tag[] listaTags = new Tag[espacioComun.listaTags.Count]; espacioComun.listaTags.CopyTo(listaTags); espacioComun.listaTags.RemoveAll(tag => true); db.espacioComun.AddOrUpdate(espacioComun); db.SaveChanges(); EspacioComun espacioAux = db.espacioComun.Include("listaTags").Single(a => a.id == espacioComun.id); ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, espacioAux.listaTags); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para Insertar un nuevo Matricula. /// </summary> /// <param name="RatingEvento"></param> public void grabar(RatingEvento RatingEvento) { try { using (var db = new ModeloRenacer()) { db.rating.AddOrUpdate(RatingEvento); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
public List <Inscripcion> devolverInscripcionXSocio(int idSocio) { try { using (var db = new ModeloRenacer()) { return(db.inscripcion .Include("listaPagos") .Include("evento") .Where(x => x.idSocio == idSocio && x.fechaBaja == null) .ToList()); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } return(null); }
public void update(Inscripcion inscripcion) { try { using (var db = new ModeloRenacer()) { db.inscripcion.AddOrUpdate(inscripcion); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
public List <TipoDocumento> devolverTiposDocumentos() { try { using (var db = new ModeloRenacer()) { return(db.tipoDocumento.ToList()); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); var tt = new TipoDocumento(); tt.nombre = ex.Message; var lista = new List <TipoDocumento>(); lista.Add(tt); return(lista); } //return null; }
/// <summary> /// Metodo utilizado para Insertar un nuevo evento. /// </summary> /// <param name="evento"></param> //public void grabar(Evento evento) //{ // try // { // var errores = this.validar(evento); // if (errores.Count > 0) // { // throw new UsuarioException(errores); // } // evento.fechaCreacion = DateTime.Now; // evento.fechaModificacion = DateTime.Now; // using (var db = new ModeloRenacer()) // { // if (evento.responsable != null) // { // evento.responsable = db.encargado.Single(a => a.id == evento.responsable.id); // db.Entry(evento.responsable).State = System.Data.Entity.EntityState.Unchanged; // evento.responsable.domicilio = db.domicilio.Single(a => a.id == evento.responsable.idDomicilio); // } // if (evento.espacio != null) // { // evento.espacio = db.espacioComun.Single(a => a.id == evento.espacio.id); // db.Entry(evento.espacio).State = System.Data.Entity.EntityState.Unchanged; // } // if (evento.tipoEvento != null) // { // evento.tipoEvento = db.tipoEvento.Single(a => a.id == evento.tipoEvento.id); // evento.idTipoEvento = evento.tipoEvento.id; // db.Entry(evento.tipoEvento).State = System.Data.Entity.EntityState.Unchanged; // } // Tag[] listaTags = { }; // if (evento.listaTags != null && evento.listaTags.Count > 0) // { // listaTags = new Tag[evento.listaTags.Count]; // evento.listaTags.CopyTo(listaTags); // evento.listaTags.RemoveAll(tag => true); // } // foreach (DetalleEvento detalle in evento.listaDetalleEvento) // { // detalle.espacio = evento.espacio; // detalle.idEspacio = evento.idEspacio; // db.Entry(detalle.espacio).State = System.Data.Entity.EntityState.Unchanged; // detalle.idEncargado = evento.idEncargado; // detalle.responsable = evento.responsable; // detalle.idEspacio = evento.idEspacio; // db.Entry(detalle.responsable).State = System.Data.Entity.EntityState.Unchanged; // db.Entry(detalle.espacio).State = System.Data.Entity.EntityState.Unchanged; // if (string.IsNullOrEmpty(detalle.nombre)) detalle.nombre = evento.nombre; // if (string.IsNullOrEmpty(detalle.descripcion)) detalle.descripcion = evento.descripcion; // detalle.fechaCreacion = DateTime.Now; // detalle.fechaModificacion = DateTime.Now; // } // Socio[] listaSocios = { }; // if (evento.listaSocios != null && evento.listaSocios.Count > 0) // { // listaSocios = new Socio[evento.listaSocios.Count]; // evento.listaSocios.CopyTo(listaSocios); // evento.listaSocios.RemoveAll(socio => true); // } // Inscripcion[] listaInscripciones = { }; // if (evento.listaInscripciones != null && evento.listaInscripciones.Count > 0) // { // listaInscripciones = new Inscripcion[evento.listaInscripciones.Count]; // evento.listaInscripciones.CopyTo(listaInscripciones); // evento.listaInscripciones = new List<Inscripcion>(); // } // db.evento.AddOrUpdate(evento); // db.SaveChanges(); // if (listaInscripciones.Length > 0) // { // foreach (var inscripto in listaInscripciones) { // inscripto.fechaCreacion = DateTime.Now; // inscripto.fechaModificacion = DateTime.Now; // inscripto.Socio = db.socio.Where(enc => enc.id == inscripto.idSocio).FirstOrDefault(); // inscripto.Evento = evento; // db.Entry(inscripto).State = System.Data.Entity.EntityState.Added; // } // evento.listaInscripciones.AddRange(listaInscripciones); // } // db.evento.AddOrUpdate(evento); // db.SaveChanges(); // Evento eventoAux = db.evento.Include("listaTags").Single(a => a.id == evento.id); // ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, eventoAux.listaTags); // if (evento.listaSocios != null && evento.listaSocios.Count > 0) ControlSocio.devolverInstancia().actualizarListaDeSocios(db, listaSocios, eventoAux.listaSocios); // db.SaveChanges(); // } // } // catch (UsuarioException ex) // { // ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); // throw ex; // } // catch (Exception ex) // { // ServicioSentry.devolverSentry().informarExcepcion(ex); // } //} public void grabar(Evento evento) { try { List <Cuota> cuotas = new List <Cuota>(); evento.fechaCreacion = DateTime.Now; diasSemamas(evento.listaHorarios); List <DetalleEvento> detalleEventos = diasEntreDosFechas(evento.fechaDesde, evento.fechaHasta, evento.listaHorarios, evento); evento.listaDetalleEvento = detalleEventos; if (!evento.gratuito) { for (int i = 1; i <= evento.cantidadCuota; i++) { Cuota cuota = new Cuota(); cuota.nombre = "Cuota " + i; cuota.monto = (decimal)(evento.monto / evento.cantidadCuota); cuota.fechaVencimiento = evento.fechaHastaInscripcion.AddMonths(i); cuotas.Add(cuota); } evento.listaCuotas = cuotas; } using (var db = new ModeloRenacer()) { db.evento.Add(evento); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para Insertar un nuevo Matricula. /// </summary> /// <param name="Matricula"></param> public void grabar(Secretario secretario) { try { //var errores = this.validar(Matricula); //if (errores.Count > 0) //{ // throw new UsuarioException(errores); //} using (var db = new ModeloRenacer()) { if (secretario.tipoDoc != null) { secretario.idTipoDoc = secretario.tipoDoc.id; secretario.tipoDoc = null; } if (secretario.id == 0) { db.Entry(secretario).State = EntityState.Added; } else { db.Entry(secretario).State = EntityState.Modified; } db.secretario.AddOrUpdate(secretario); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// var item = (from i in db.encargado /// where i.id.Equals(id) // select i).FirstOrDefault(); /// /// /// SELECT * FROM Encargado WHERE id = 1; public Encargado devolver(int id) { try { using (var db = new ModeloRenacer()) { var itemEncargado = db.encargado. Include("tipoDoc"). Include("domicilio"). Where(x => x.id.Equals(id)).FirstOrDefault(); //itemEncargado.listaTags = db.tag.Where(x => x.listaEncargados.Any(xy => xy.id.Equals(id))).ToList(); return(itemEncargado); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } return(null); }
/// <summary> /// Metodo utilizado para Insertar un nuevo detalleEvento. /// </summary> /// <param name="detalleEvento"></param> public void grabar(DetalleEvento detalleEvento) { try { var errores = this.validar(detalleEvento); if (errores.Count > 0) { throw new UsuarioException(errores); } using (var db = new ModeloRenacer()) { if (detalleEvento.espacio != null) { detalleEvento.espacio = db.espacioComun.Single(a => a.id == detalleEvento.espacio.id); } //if (detalleEvento.asistencia != null) // detalleEvento.asistencia = db.asistencia.Single(a => a.id == detalleEvento.asistencia.id); if (detalleEvento.responsable != null) { detalleEvento.responsable = db.encargado.Single(a => a.id == detalleEvento.responsable.id); } db.detalleEvento.Add(detalleEvento); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
public List <Recordatorio> devolverDiaHoy() { List <Recordatorio> recordatorios = new List <Recordatorio>(); try { using (var db = new ModeloRenacer()) { var personas_db = db.Database.SqlQuery <Recordatorio>("SELECT * FROM renacer.recordatorios where LEFT(fechaRecordatorio ,10) =CURDATE()"); foreach (var item in personas_db) { recordatorios.Add(item); } return(recordatorios); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } return(null); }
/// <summary> /// Metodo utilizado para Insertar un nuevo asistencia. /// </summary> /// <param name="asistencia"></param> public void grabar(Asistencia asistencia) { try { var errores = this.validar(asistencia); if (errores.Count > 0) { throw new UsuarioException(errores); } //if (asistencia.id == 0) asistencia.fechaCreacion = DateTime.Now; //if (asistencia.id > 0) asistencia.fechaModificacion = DateTime.Now; using (var db = new ModeloRenacer()) { //Socio[] listaSocios = new Socio[asistencia.listaSocios.Count]; //asistencia.listaSocios.CopyTo(listaSocios); //asistencia.listaSocios.RemoveAll(soc => true); asistencia.fechaAsistencia = DateTime.Now; db.asistencia.Add(asistencia); db.SaveChanges(); // asistencia = db.asistencia.Include("listaSocios").Single(a => a.id == asistencia.id); //ControlSocio.devolverInstancia().actualizarListaDeSocios(db, listaSocios, asistencia.listaSocios); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
public List <Calendario> devolverTodosCalendario(DateTime fechaDesde, DateTime fechaHasta, int idEspacio) { try { List <Calendario> listaCalendario = new List <Calendario>(); using (var db = new ModeloRenacer()) { List <DetalleEvento> listaDetalle = db.detalleEvento. Include("espacio"). Include("responsable") .Where(ev => ev.fechaDesde >= fechaDesde && ev.fechaDesde <= fechaHasta && ev.fechaBaja == null) .Where(ev => ev.idEspacio == idEspacio || idEspacio == 0) .ToList(); foreach (var item in listaDetalle) { Calendario itemCalendario = new Calendario(); itemCalendario.id = item.id; itemCalendario.nombre = item.nombre; itemCalendario.descripcion = item.descripcion; itemCalendario.idEvento = item.idEvento; itemCalendario.dia = item.dia; itemCalendario.fechaDesde = item.fechaDesde; itemCalendario.fechaHasta = item.fechaHasta; itemCalendario.aula = item.espacio.nombre; itemCalendario.encargado = item.responsable.nombre + " " + item.responsable.apellido; listaCalendario.Add(itemCalendario); } return(listaCalendario); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } return(null); }
public Usuario devolverPorToken(string token) { try { using (var db = new ModeloRenacer()) { var userLog = db.usuario. Where(x => x.token.Equals(token)).FirstOrDefault(); userLog.clave = ""; if (!System.IO.File.Exists(userLog.imagen)) { userLog.imagen = ""; } return(userLog); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } return(null); }
/// <summary> /// Metodo utilizado para Insertar un nuevo inscripcion. /// </summary> /// <param name="inscripcion"></param> public void grabar(Inscripcion inscripcion) { try { var errores = this.validar(inscripcion); if (errores.Count > 0) { throw new UsuarioException(errores); } Evento evento = ControlEvento.devolverInstancia().devolver(inscripcion.idEvento); evento.estadoDeudores = "ADEUDADO"; ControlEvento.devolverInstancia().actualizar(evento); List <Pago> listaPagos = new List <Pago>(); if (inscripcion.id == 0) { inscripcion.fechaCreacion = DateTime.Now; } if (!evento.gratuito) { int contador = 1; foreach (var cuota in evento.listaCuotas) { Pago pago = new Pago(); pago.nombre = "Cuota " + contador; pago.monto = (float)(evento.monto / evento.cantidadCuota); pago.idCuota = cuota.id; listaPagos.Add(pago); contador++; } inscripcion.listaPagos = listaPagos; } using (var db = new ModeloRenacer()) { if (inscripcion.socio != null) { db.Entry(inscripcion.socio).State = System.Data.Entity.EntityState.Unchanged; } if (inscripcion.evento != null) { db.Entry(inscripcion.evento).State = System.Data.Entity.EntityState.Unchanged; } db.inscripcion.AddOrUpdate(inscripcion); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para Insertar un nuevo socio. /// </summary> /// <param name="socio"></param> public Socio grabar(Socio socio) { try { var errores = this.validar(socio); if (errores.Count > 0) { throw new UsuarioException(errores); } using (var db = new ModeloRenacer()) { socio.nombre = socio.nombre.ToUpper(); socio.apellido = socio.apellido.ToUpper(); socio.idTipoDoc = socio.tipoDoc.id; Tag[] listaTags = new Tag[socio.listaTags.Count]; socio.listaTags.CopyTo(listaTags); socio.listaTags.RemoveAll(tag => true); if (socio.domicilio.id == 0) { db.Entry(socio.domicilio).State = System.Data.Entity.EntityState.Added; } if (socio.domicilio.id > 0) { db.Entry(socio.domicilio).State = System.Data.Entity.EntityState.Modified; } if (socio.contacto.id == 0) { db.Entry(socio.contacto).State = System.Data.Entity.EntityState.Added; } if (socio.contacto.id > 0) { db.Entry(socio.contacto).State = System.Data.Entity.EntityState.Modified; } db.Entry(socio.tipoDoc).State = System.Data.Entity.EntityState.Unchanged; db.socio.AddOrUpdate(socio); db.SaveChanges(); //EspacioComun espacioAux = db.espacioComun.Include("listaTags").Single(a => a.id == espacioComun.id); //ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, espacioAux.listaTags); Socio socioAux = db.socio.Include("listaTags").Single(a => a.id == socio.id); ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, socioAux.listaTags); db.SaveChanges(); return(socio); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); return(null); } }
public void actualizar(Evento evento) { try { var errores = this.validar(evento); if (errores.Count > 0) { throw new UsuarioException(errores); } //evento.fechaModificacion = DateTime.Now; using (var db = new ModeloRenacer()) { //if (evento.responsable != null) //{ // evento.responsable = db.encargado.Single(a => a.id == evento.responsable.id); // db.Entry(evento.responsable).State = System.Data.Entity.EntityState.Unchanged; // evento.responsable.domicilio = db.domicilio.Single(a => a.id == evento.responsable.idDomicilio); //} //if (evento.espacio != null) //{ // evento.espacio = db.espacioComun.Single(a => a.id == evento.espacio.id); // db.Entry(evento.espacio).State = System.Data.Entity.EntityState.Unchanged; //} //if (evento.tipoEvento != null) //{ // evento.tipoEvento = db.tipoEvento.Single(a => a.id == evento.tipoEvento.id); // evento.idTipoEvento = evento.tipoEvento.id; // db.Entry(evento.tipoEvento).State = EntityState.Unchanged; //} //if (evento.listaInscripciones != null) //{ // db.Entry(evento.listaInscripciones).State = EntityState.Modified; //} //Tag[] listaTags = { }; //if (evento.listaTags != null && evento.listaTags.Count > 0) //{ // listaTags = new Tag[evento.listaTags.Count]; // evento.listaTags.CopyTo(listaTags); // evento.listaTags.RemoveAll(tag => true); //} //Socio[] listaSocios = { }; //if (evento.listaSocios != null && evento.listaSocios.Count > 0) //{ // listaSocios = new Socio[evento.listaSocios.Count]; // evento.listaSocios.CopyTo(listaSocios); // evento.listaSocios.RemoveAll(socio => true); //} //Inscripcion[] listaInscripciones = { }; //if (evento.listaInscripciones != null && evento.listaInscripciones.Count > 0) //{ // listaInscripciones = new Inscripcion[evento.listaInscripciones.Count]; // evento.listaInscripciones.CopyTo(listaInscripciones); // evento.listaInscripciones.RemoveAll(inscrip => true); // foreach (var inscripto in listaInscripciones) // { // inscripto.fechaCreacion = DateTime.Now; // inscripto.fechaModificacion = DateTime.Now; // inscripto.Socio = db.socio.Where(enc => enc.id == inscripto.idSocio).FirstOrDefault(); // inscripto.Evento = evento; // db.Entry(inscripto).State = System.Data.Entity.EntityState.Added; // } // evento.listaInscripciones.AddRange(listaInscripciones); //} //Evento eventoAux = db.evento.Include("listaTags").Single(a => a.id == evento.id); //ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, eventoAux.listaTags); //if (evento.listaSocios != null && evento.listaSocios.Count > 0) ControlSocio.devolverInstancia().actualizarListaDeSocios(db, listaSocios, eventoAux.listaSocios); // ControlDetalleEvento.devolverInstancia().actualizarListaDeDetalleEventos(db, listaDetalleEvento, eventoAux.listaDetalleEvento); //db.Entry(evento.listaInscripciones).State = EntityState.Modified; //db.Entry(evento).State = EntityState.Unchanged; //foreach (var item in evento.listaInscripciones) //{ // item.evento.id = item.idEvento; //} //evento.listaInscripciones.ForEach(p => db.Entry(p).State = EntityState.Added); //var entity = db.evento.Find(evento.id); //db.Entry(entity).CurrentValues.SetValues(evento); db.evento.AddOrUpdate(evento); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }