public void BorrarUnComentario(int id_comentario) { /*PROTECTED REGION ID(WhateverGenNHibernate.CP.Whatever_Comentario_borrarUnComentario) ENABLED START*/ IComentarioCAD comentarioCAD = null; ComentarioCEN comentarioCEN = null; try { SessionInitializeTransaction(); comentarioCAD = new ComentarioCAD(session); comentarioCEN = new ComentarioCEN(comentarioCAD); // Write here your custom transaction ... EventoEN even = new EventoEN(); even = comentarioCAD.GetID(id_comentario).Evento; RetoEN reten = new RetoEN(); reten = comentarioCAD.GetID(id_comentario).Reto; GymkanaEN gymen = new GymkanaEN(); gymen = comentarioCAD.GetID(id_comentario).Gymkana; if (even != null) { comentarioCAD.UnrelationerComentarioEvento(id_comentario, even.ID); comentarioCAD.Destroy(id_comentario); } else if (reten != null) { comentarioCAD.UnrelationerComentarioReto(id_comentario, reten.ID); comentarioCAD.Destroy(id_comentario); } else if (gymen != null) { comentarioCAD.UnrelationerComentarioGymkana(id_comentario, gymen.ID); comentarioCAD.Destroy(id_comentario); } SessionCommit(); } catch (Exception ex) { SessionRollBack(); throw ex; } finally { SessionClose(); } /*PROTECTED REGION END*/ }
public void BorrarComentariosReto(int id_reto) { /*PROTECTED REGION ID(WhateverGenNHibernate.CP.Whatever_Comentario_borrarComentariosReto) ENABLED START*/ IComentarioCAD comentarioCAD = null; ComentarioCEN comentarioCEN = null; try { SessionInitializeTransaction(); comentarioCAD = new ComentarioCAD(session); comentarioCEN = new ComentarioCEN(comentarioCAD); // Write here your custom transaction ... System.Collections.Generic.IList <ComentarioEN> comentarios = new System.Collections.Generic.List <ComentarioEN>(); comentarios = comentarioCAD.FiltrarComentarioPorReto(id_reto); foreach (ComentarioEN element in comentarios) { comentarioCAD.UnrelationerComentarioReto(element.ID, id_reto); comentarioCAD.Destroy(element.ID); } SessionCommit(); } catch (Exception ex) { SessionRollBack(); throw ex; } finally { SessionClose(); } /*PROTECTED REGION END*/ }