public Respuesta <SaldoParticipante> anulacionSaldos(Inscripcion data) { Respuesta <SaldoParticipante> result = new Respuesta <SaldoParticipante>(); result.codigo = 0; result.mensaje = "Ocurrio un Error en base de datos"; result.data = new SaldoParticipante(); try { using (var db = new EntitiesEVE01()) { //SE OBTINE EL REGISTRO PARA SU ELIMINACION var saldos = (from s in db.EVE01_PARTICIPANTE_SALDO where s.EVENTO == MvcApplication.idEvento && s.PARTICIPANTE == data.idParticipante select s).SingleOrDefault(); db.EVE01_PARTICIPANTE_SALDO.Remove(saldos); db.SaveChanges(); } result.codigo = 0; result.mensaje = "Ok"; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al eliminar el Saldo Inicial, ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
public Respuesta <SaldoParticipante> registrarSaldoInicial(Inscripcion data) { Respuesta <SaldoParticipante> result = new Respuesta <SaldoParticipante>(); result.codigo = 0; result.mensaje = "Ocurrio un Error en base de datos"; result.data = new SaldoParticipante(); try { using (var db = new EntitiesEVE01()) { //SE REALIZA LA SUMATORIA DEL PRECIO DE LAS OPCIONES OBLIGATORIAS var total = (from io in db.EVE01_INSCRIPCION_OPCION join oe in db.EVE01_EVENTO_OPCION on new { io.EVENTO, io.OPCION } equals new { oe.EVENTO, oe.OPCION } where io.EVENTO == MvcApplication.idEvento && io.PARTICIPANTE == data.idParticipante && io.ESTADO_REGISTRO == "A" select oe.PRECIO).Sum(); //Y SE INSERTAN EN LA TABLA DE SALDOS if (total > 0) { EVE01_PARTICIPANTE_SALDO nuevo = new EVE01_PARTICIPANTE_SALDO(); nuevo.EVENTO = MvcApplication.idEvento; nuevo.PARTICIPANTE = data.idParticipante; nuevo.TOTAL = total; nuevo.SALDO_ABONADO = 0; nuevo.SALDO_PENDIENTE = total; nuevo.ESTADO_REGISTRO = "A"; nuevo.USUARIO_CREACION = MvcApplication.UserName.ToUpper(); nuevo.FECHA_CREACION = DateTime.Now; db.EVE01_PARTICIPANTE_SALDO.Add(nuevo); db.SaveChanges(); } } result.codigo = 0; result.mensaje = "Ok"; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al registrar el Saldo Inicial, ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
public Respuesta <List <EventoBus> > busesDisponiblesParticipante(Inscripcion data) { Respuesta <List <EventoBus> > result = new Respuesta <List <EventoBus> >(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de Datos"; result.data = new List <EventoBus>(); try { using (var db = new EntitiesEVE01()) { var buses = (from b in db.EVE01_EVENTO_BUS where b.EVENTO == MvcApplication.idEvento && b.ESTADO_REGISTRO == "A" select b).ToList(); if (buses.Count == 0) { result.codigo = -1; result.mensaje = "No Existen Buses registrados para este Evento"; return(result); } else { foreach (var item in buses) { if (item.DISPONIBLE != 0 || validaAsignacion(data.idParticipante, item.BUS)) //REVISA SI HAY LUGARES DISPONIBLES PARA LUEGO MOSTRAR EN INTERFACE GRAFICA { result.data.Add(new EventoBus(item) { validabusasignado = validaAsignacion(data.idParticipante, item.BUS) }); } } } } result.codigo = 0; result.mensaje = "Ok"; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al obtener el listado de buses disponibles, ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
//METODO QUE INACTIVA LAS OPCIONES DE INSCRIPCION AL MOMENTO DE ANULAR LA INSCRIPCION public Respuesta <InscripcionOpcion> eliminarOpcionesInscripcion(Inscripcion data) { Respuesta <InscripcionOpcion> result = new Respuesta <InscripcionOpcion>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en Base de Datos"; result.data = new InscripcionOpcion(); try { using (var tr = new TransactionScope()) { using (var db = new EntitiesEVE01()) { var listadoOpciones = db.EVE01_INSCRIPCION_OPCION. Where(o => o.PARTICIPANTE == data.idParticipante && o.EVENTO == MvcApplication.idEvento). Select(o => o).ToList(); if (listadoOpciones.Count == 0) { result.codigo = -1; result.mensaje = "No existen Opciones para la Inscripcion indicada"; result.data = new InscripcionOpcion(); return(result); } else { foreach (var item in listadoOpciones) { var del = db.EVE01_INSCRIPCION_OPCION. Where(d => d.PARTICIPANTE == item.PARTICIPANTE && d.EVENTO == item.EVENTO && d.OPCION == item.OPCION). Select(d => d).SingleOrDefault(); db.EVE01_INSCRIPCION_OPCION.Remove(del); int re = db.SaveChanges(); if (re <= 0) { Transaction.Current.Rollback(); result.codigo = -2; result.mensaje = "No fue posible eliminar la opcion"; return(result); } } //SI EN LAS OPCIONES TIENE ASIGNADO BUS SE PROCEDE A ELIMINAR Y ACTUALIZAR LA DISPONIBILIDAD DE BUS PARA OTRO PARTICIPANTE var tienebusAsignado = (from ob in db.EVE01_INSCRIPCION_BUS where ob.EVENTO == MvcApplication.idEvento && ob.PARTICIPANTE == data.idParticipante select ob).SingleOrDefault(); if (tienebusAsignado != null) { var actualizarInfoBus = (from aib in db.EVE01_EVENTO_BUS where aib.EVENTO == tienebusAsignado.EVENTO && aib.BUS == tienebusAsignado.BUS select aib).SingleOrDefault(); actualizarInfoBus.DISPONIBLE++; actualizarInfoBus.OCUPADO--; actualizarInfoBus.USUARIO_MODIFICACION = MvcApplication.UserName; actualizarInfoBus.FECHA_MODIFICACION = DateTime.Now; int rba = db.SaveChanges(); if (rba <= 0) { Transaction.Current.Rollback(); result.codigo = -2; result.mensaje = "No fue posible Actualizar Informacion el Bus Anterior"; return(result); } var busAsignado = (from ba in db.EVE01_INSCRIPCION_BUS where ba.EVENTO == tienebusAsignado.EVENTO && ba.PARTICIPANTE == tienebusAsignado.PARTICIPANTE && ba.BUS == tienebusAsignado.BUS select ba).SingleOrDefault(); db.EVE01_INSCRIPCION_BUS.Remove(busAsignado); int re = db.SaveChanges(); if (re <= 0) { Transaction.Current.Rollback(); result.codigo = -2; result.mensaje = "No fue posible eliminar el bus de la Inscripcion"; return(result); } } } } tr.Complete(); } result.codigo = 0; result.mensaje = "Se eliminaron las opciones agregadas en la Inscripcion"; result.data = new InscripcionOpcion(); return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al eliminar las opciones de la Inscripcion, Ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
public Respuesta <InscripcionOpcion> agregarOpcionesInscripcion(Inscripcion data) { Respuesta <InscripcionOpcion> result = new Respuesta <InscripcionOpcion>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en Base de Datos"; result.data = new InscripcionOpcion(); try { using (var tr = new TransactionScope()) { using (var db = new EntitiesEVE01()) { //SE OBTIENE EL LISTADO DE OPCIONES REGISTRADAS PARA EL EVENTO ACTUAL var listadoOpciones = db.EVE01_EVENTO_OPCION. Where(o => o.EVENTO == MvcApplication.idEvento && o.ESTADO_REGISTRO == "A"). Select(o => o).ToList(); //SE EVALUA SI EXISTEN LAS OPCIONES if (listadoOpciones.Count == 0) { result.codigo = 1; result.mensaje = "No existen Opciones para este Evento"; return(result); } else { //SE RECORRE EL LISTADO DE LAS OPCIONES Y POR CADA UNA QUE SE ENCUENTRA SE INSERTAN EN LA TABLA EVE01_INSCRIPCION_OPCION foreach (var item in listadoOpciones) { EVE01_INSCRIPCION_OPCION opcion = new EVE01_INSCRIPCION_OPCION(); opcion.PARTICIPANTE = data.idParticipante; opcion.EVENTO = MvcApplication.idEvento; opcion.OPCION = item.OPCION; //SI LA OPCION ES OBLIGATORIA, SE REGISTRA EN ESTADO "A" DE LO CONTRARIO EN ESTADO "B" if (item.OBLIGATORIO == "S") { opcion.ESTADO_REGISTRO = "A"; } else { opcion.ESTADO_REGISTRO = "B"; } opcion.USUARIO_CREACION = MvcApplication.UserName; opcion.FECHA_CREACION = DateTime.Now; db.EVE01_INSCRIPCION_OPCION.Add(opcion); int res_op = db.SaveChanges(); if (res_op <= 0) { Transaction.Current.Rollback(); result.codigo = 2; result.mensaje = "No fue Posible Registrar las Opciones"; return(result); } } } //SE REGISTRA EL SALDO INICIAL SaldoParticipante nuevo = new SaldoParticipante(); Respuesta <SaldoParticipante> respuesta = nuevo.registrarSaldoInicial(data); if (respuesta.codigo != 0) { Transaction.Current.Rollback(); result.codigo = respuesta.codigo; result.mensaje = respuesta.mensajeError; return(result); } } tr.Complete(); result.codigo = 0; result.mensaje = "Se agregaron correctamente las opciones del Evento"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al momento de agregar las opciones del Evento, Ref:" + ex.ToString(); return(result); } }