public ActionResult Check(int id) { // TODO comprobar que pertecene a usuario actual // Utilizando session no funciona //SessionInitialize(); //LineaListaCompraCAD lineaListaCompraCad = new LineaListaCompraCAD(session); //LineaListaCompraCEN lineaListaCompraCen = new LineaListaCompraCEN(lineaListaCompraCad); //LineaListaCompraEN en = lineaListaCompraCad.ReadOIDDefault(id); ////lineaListaCompraCen.Modify(en.Id, en.Cantidad, en.Unidad, !en.Comprado); ////lineaListaCompraEn.Comprado = !lineaListaCompraEn.Comprado; ////lineaListaCompraCad.Modify(lineaListaCompraEn); //SessionClose(); int idListaCompra = -1; LineaListaCompraCAD cad = new LineaListaCompraCAD(); LineaListaCompraEN en = new LineaListaCompraEN(); en = cad.ReadOIDDefault(id); idListaCompra = en.ListaCompra.Id; // No da lazyException... Solo se puede acceder al ID para que no dé. en.Comprado = !en.Comprado; cad.Modify(en); return(RedirectToAction("Index", new { id = idListaCompra })); }
public LineaListaCompraEN ReadOIDDefault (int id) { LineaListaCompraEN lineaListaCompraEN = null; try { SessionInitializeTransaction (); lineaListaCompraEN = (LineaListaCompraEN)session.Get (typeof(LineaListaCompraEN), id); SessionCommit (); } catch (Exception ex) { SessionRollBack (); if (ex is EnMiNeveraGenNHibernate.Exceptions.ModelException) throw ex; throw new EnMiNeveraGenNHibernate.Exceptions.DataLayerException ("Error in LineaListaCompraCAD.", ex); } finally { SessionClose (); } return lineaListaCompraEN; }
public void Modify (LineaListaCompraEN lineaListaCompra) { try { SessionInitializeTransaction (); LineaListaCompraEN lineaListaCompraEN = (LineaListaCompraEN)session.Load (typeof(LineaListaCompraEN), lineaListaCompra.Id); lineaListaCompraEN.Cantidad = lineaListaCompra.Cantidad; lineaListaCompraEN.Unidad = lineaListaCompra.Unidad; lineaListaCompraEN.Comprado = lineaListaCompra.Comprado; session.Update (lineaListaCompraEN); SessionCommit (); } catch (Exception ex) { SessionRollBack (); if (ex is EnMiNeveraGenNHibernate.Exceptions.ModelException) throw ex; throw new EnMiNeveraGenNHibernate.Exceptions.DataLayerException ("Error in LineaListaCompraCAD.", ex); } finally { SessionClose (); } }
public void CrearLineaListaCompra(int p_oid, int p_cantidad, EnMiNeveraGenNHibernate.Enumerated.EnMiNevera.UnidadesEnum p_unidad, string p_ingrediente) { IngredienteEN ingredienteEN = null; LineaListaCompraEN lineaListaCompraEN = null; int oid_ingrediente; try { SessionInitializeTransaction(); IngredienteCAD ingredienteCAD = new IngredienteCAD(session); ingredienteEN = ingredienteCAD.GetPorNombre(p_ingrediente.ToLower()); if (ingredienteEN == null) { // Creamos el ingrediente si no existe ingredienteEN = new IngredienteEN(); ingredienteEN.Nombre = p_ingrediente.ToLower(); oid_ingrediente = ingredienteCAD.New_(ingredienteEN); ingredienteEN = ingredienteCAD.ReadOIDDefault(oid_ingrediente); } else { oid_ingrediente = ingredienteEN.Id; } LineaListaCompraCAD lineaListaCompraCAD = new LineaListaCompraCAD(session); lineaListaCompraEN = new LineaListaCompraEN(); lineaListaCompraEN.Ingrediente = ingredienteCAD.ReadOIDDefault(oid_ingrediente); lineaListaCompraEN.Cantidad = p_cantidad; lineaListaCompraEN.Unidad = p_unidad; lineaListaCompraEN.Comprado = false; lineaListaCompraEN.Ingrediente.Nombre = p_ingrediente.ToLower(); lineaListaCompraCAD.New_(lineaListaCompraEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); throw ex; } finally { SessionClose(); } }
public ActionResult Remove(int id) { // TODO comprobar que pertecene a usuario actual // Obtengo en que lista de la compra estoy LineaListaCompraCAD cad = new LineaListaCompraCAD(); LineaListaCompraEN en = cad.ReadOIDDefault(id); int idListaCompra = en.ListaCompra.Id; cad.Destroy(id); return(RedirectToAction("Index", new { id = idListaCompra })); }
public void Modify(int p_LineaListaCompra_OID, int p_cantidad, EnMiNeveraGenNHibernate.Enumerated.EnMiNevera.UnidadesEnum p_unidad, bool p_comprado) { LineaListaCompraEN lineaListaCompraEN = null; //Initialized LineaListaCompraEN lineaListaCompraEN = new LineaListaCompraEN(); lineaListaCompraEN.Id = p_LineaListaCompra_OID; lineaListaCompraEN.Cantidad = p_cantidad; lineaListaCompraEN.Unidad = p_unidad; lineaListaCompraEN.Comprado = p_comprado; //Call to LineaListaCompraCAD _ILineaListaCompraCAD.Modify(lineaListaCompraEN); }
public void DesmarcarComprado(int p_oid) { /*PROTECTED REGION ID(EnMiNeveraGenNHibernate.CEN.EnMiNevera_LineaListaCompra_desmarcarComprado) ENABLED START*/ // Write here your custom code... LineaListaCompraEN lineaListaCompraEN = null; lineaListaCompraEN = _ILineaListaCompraCAD.ReadOIDDefault(p_oid); lineaListaCompraEN.Comprado = false; _ILineaListaCompraCAD.Modify(lineaListaCompraEN); //throw new NotImplementedException("Method DesmarcarComprado() not yet implemented."); /*PROTECTED REGION END*/ }
public int New_ (LineaListaCompraEN lineaListaCompra) { try { SessionInitializeTransaction (); if (lineaListaCompra.Ingrediente != null) { // Argumento OID y no colección. lineaListaCompra.Ingrediente = (EnMiNeveraGenNHibernate.EN.EnMiNevera.IngredienteEN)session.Load (typeof(EnMiNeveraGenNHibernate.EN.EnMiNevera.IngredienteEN), lineaListaCompra.Ingrediente.Id); lineaListaCompra.Ingrediente.LineasListaCompra .Add (lineaListaCompra); } if (lineaListaCompra.ListaCompra != null) { // Argumento OID y no colección. lineaListaCompra.ListaCompra = (EnMiNeveraGenNHibernate.EN.EnMiNevera.ListaCompraEN)session.Load (typeof(EnMiNeveraGenNHibernate.EN.EnMiNevera.ListaCompraEN), lineaListaCompra.ListaCompra.Id); lineaListaCompra.ListaCompra.LineasListaCompra .Add (lineaListaCompra); } session.Save (lineaListaCompra); SessionCommit (); } catch (Exception ex) { SessionRollBack (); if (ex is EnMiNeveraGenNHibernate.Exceptions.ModelException) throw ex; throw new EnMiNeveraGenNHibernate.Exceptions.DataLayerException ("Error in LineaListaCompraCAD.", ex); } finally { SessionClose (); } return lineaListaCompra.Id; }
public void Destroy (int id) { try { SessionInitializeTransaction (); LineaListaCompraEN lineaListaCompraEN = (LineaListaCompraEN)session.Load (typeof(LineaListaCompraEN), id); session.Delete (lineaListaCompraEN); SessionCommit (); } catch (Exception ex) { SessionRollBack (); if (ex is EnMiNeveraGenNHibernate.Exceptions.ModelException) throw ex; throw new EnMiNeveraGenNHibernate.Exceptions.DataLayerException ("Error in LineaListaCompraCAD.", ex); } finally { SessionClose (); } }
public int New_(int p_cantidad, EnMiNeveraGenNHibernate.Enumerated.EnMiNevera.UnidadesEnum p_unidad, int p_ingrediente, int p_listaCompra, bool p_comprado) { LineaListaCompraEN lineaListaCompraEN = null; int oid; //Initialized LineaListaCompraEN lineaListaCompraEN = new LineaListaCompraEN(); lineaListaCompraEN.Cantidad = p_cantidad; lineaListaCompraEN.Unidad = p_unidad; if (p_ingrediente != -1) { // El argumento p_ingrediente -> Property ingrediente es oid = false // Lista de oids id lineaListaCompraEN.Ingrediente = new EnMiNeveraGenNHibernate.EN.EnMiNevera.IngredienteEN(); lineaListaCompraEN.Ingrediente.Id = p_ingrediente; } if (p_listaCompra != -1) { // El argumento p_listaCompra -> Property listaCompra es oid = false // Lista de oids id lineaListaCompraEN.ListaCompra = new EnMiNeveraGenNHibernate.EN.EnMiNevera.ListaCompraEN(); lineaListaCompraEN.ListaCompra.Id = p_listaCompra; } lineaListaCompraEN.Comprado = p_comprado; //Call to LineaListaCompraCAD oid = _ILineaListaCompraCAD.New_(lineaListaCompraEN); return(oid); }