Exemplo n.º 1
0
        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 ();
            }
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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 });
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            LineaListaCompraEN t = obj as LineaListaCompraEN;

            if (t == null)
            {
                return(false);
            }
            if (Id.Equals(t.Id))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
 public LineaListaCompraEN(LineaListaCompraEN lineaListaCompra)
 {
     this.init (Id, lineaListaCompra.Cantidad, lineaListaCompra.Unidad, lineaListaCompra.Ingrediente, lineaListaCompra.ListaCompra, lineaListaCompra.Receta, lineaListaCompra.Comprado);
 }
Exemplo n.º 8
0
 public LineaListaCompraEN(LineaListaCompraEN lineaListaCompra)
 {
     this.init(Id, lineaListaCompra.Cantidad, lineaListaCompra.Unidad, lineaListaCompra.Ingrediente, lineaListaCompra.ListaCompra, lineaListaCompra.Receta, lineaListaCompra.Comprado);
 }
Exemplo n.º 9
0
        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;
        }