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); } }
public InscripcionOpcion() { dbModel = new EVE01_INSCRIPCION_OPCION(); }
public InscripcionOpcion(EVE01_INSCRIPCION_OPCION datos) { dbModel = datos; }