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 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 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 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); } }
/// <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); } }