public void actualizarEstadoEvento() { List <Evento> listEventos; using (var db = new ModeloRenacer()) { listEventos = db.evento .Where(ev => ev.estado != "Cancelado" && ev.estado != "Finalizado" && ev.fechaBaja == null) .ToList(); foreach (var evento in listEventos) { if ((evento.fechaDesde <= DateTime.Now) && (DateTime.Now <= evento.fechaHasta)) { evento.estado = "Progreso"; db.evento.AddOrUpdate(evento); db.SaveChanges(); } else if (DateTime.Now >= evento.fechaHasta) { evento.estado = "Finalizado"; db.evento.AddOrUpdate(evento); db.SaveChanges(); } } } }
/// <summary> /// Metodo utilizado para Insertar un nuevo encargado. /// </summary> /// <param name="encargado"></param> public void grabar(Encargado encargado) { try { var errores = this.validar(encargado); if (errores.Count > 0) { throw new UsuarioException(errores); } if (encargado.id == 0) { encargado.fechaCreacion = DateTime.Now; } if (encargado.id > 0) { encargado.fechaModificacion = DateTime.Now; } encargado.idTipoDoc = encargado.tipoDoc.id; using (var db = new ModeloRenacer()) { Tag[] listaTags = new Tag[encargado.listaTags.Count]; encargado.listaTags.CopyTo(listaTags); encargado.listaTags.RemoveAll(tag => true); db.encargado.AddOrUpdate(encargado); if (encargado.domicilio.id == 0) { db.Entry(encargado.domicilio).State = System.Data.Entity.EntityState.Added; } if (encargado.domicilio.id > 0) { db.Entry(encargado.domicilio).State = System.Data.Entity.EntityState.Modified; } db.Entry(encargado.tipoDoc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Encargado encargadoAux = db.encargado.Include("listaTags").Single(a => a.id == encargado.id); ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, encargadoAux.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="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; } db.secretario.Add(secretario); 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 TipoDocumento. /// </summary> /// <param name="TipoDocumento"></param> public void grabar(TipoDocumento TipoDocumento) { try { var errores = this.validar(TipoDocumento); if (errores.Count > 0) { throw new UsuarioException(errores); } using (var db = new ModeloRenacer()) { db.tipoDocumento.AddOrUpdate(TipoDocumento); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para actualizar un nueva Secretario. /// </summary> /// <param name="Matricula"></param> public void update(Secretario secretario) { try { using (var db = new ModeloRenacer()) { if (secretario.tipoDoc != null) { secretario.idTipoDoc = secretario.tipoDoc.id; secretario.tipoDoc = null; } db.secretario.AddOrUpdate(secretario); 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="Recordatorio"></param> public void grabar(Recordatorio Recordatorio) { try { //var errores = this.validar(Matricula); //if (errores.Count > 0) //{ // throw new UsuarioException(errores); //} using (var db = new ModeloRenacer()) { db.recordatorio.AddOrUpdate(Recordatorio); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
public void actualizar(DetalleEvento detalleEvento) { try { 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.AddOrUpdate(detalleEvento); db.SaveChanges(); } } catch (UsuarioException ex) { ServicioSentry.devolverSentry().informarExcepcionUsuario(ex); throw ex; } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
public void actualizarSocioPagoMatricula(Socio _socio) { using (var db = new ModeloRenacer()) { _socio.estado = "Activo"; db.Entry(_socio).State = System.Data.Entity.EntityState.Modified; db.socio.AddOrUpdate(_socio); //ControlMatriculaXSocio.devolverInstacia(). Matricula matricula = ControlMatricula.devolverInstacia().devolverMatriculaActiva(); if (matricula == null) { return; } db.Entry(matricula).State = System.Data.Entity.EntityState.Modified; MatriculaXSocio matriculaxsocio = new MatriculaXSocio() { matricula = matricula, socio = _socio, fechaPago = DateTime.Now, pago = matricula.valor }; db.matriculaXSocio.Add(matriculaxsocio); db.SaveChanges(); } }
/// <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 socio. /// </summary> /// <param name="socio"></param> public void grabar(Socio socio) { try { var errores = this.validar(socio); if (errores.Count > 0) { throw new UsuarioException(errores); } using (var db = new ModeloRenacer()) { 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.SaveChanges(); Socio socioAux = db.socio.Include("listaTags").Single(a => a.id == socio.id); ControlTag.devolverInstancia().actualizarListaDeTags(db, listaTags, socioAux.listaTags); db.socio.AddOrUpdate(socio); 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 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); } }
/// <summary> /// Metodo utilizado para eliminar un inscripcion. /// TODO: El metodo se tiene que cambiar para actualizar un atributo del inscripcion /// para ver si esta eliminado o no, no se eliminan datos. /// </summary> public void eliminar(Inscripcion inscripcion) { try { using (var db = new ModeloRenacer()) { db.inscripcion.AddOrUpdate(inscripcion);// pone fechaBaja db.SaveChanges(); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para eliminar un inscripcion. /// TODO: El metodo se tiene que cambiar para actualizar un atributo del inscripcion /// para ver si esta eliminado o no, no se eliminan datos. /// </summary> public void eliminar(int id) { try { using (var db = new ModeloRenacer()) { db.inscripcion.Remove(db.inscripcion.Where(x => x.id.Equals(id)).FirstOrDefault()); db.SaveChanges(); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para eliminar un evento. /// TODO: El metodo se tiene que cambiar para actualizar un atributo del evento /// para ver si esta eliminado o no, no se eliminan datos. /// </summary> public void eliminar(Evento evento) { try { using (var db = new ModeloRenacer()) { db.evento.AddOrUpdate(evento); db.SaveChanges(); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
/// <summary> /// Metodo utilizado para eliminar un Matricula. /// TODO: El metodo se tiene que cambiar para actualizar un atributo del Matricula /// para ver si esta eliminado o no, no se eliminan datos. /// </summary> public void eliminar(int id) { try { using (var db = new ModeloRenacer()) { var secretario = ControlSecretario.devolverInstancia().devolver(id); secretario.fechaBaja = DateTime.Now; db.secretario.AddOrUpdate(secretario); db.SaveChanges(); } } catch (Exception ex) { ServicioSentry.devolverSentry().informarExcepcion(ex); } }
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); } }
/// <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); } }
/// <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 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); } }
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); } }