示例#1
0
        public void QuitarMascota(string p_Cliente_OID, System.Collections.Generic.IList <int> p_mascota_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.ClienteEN clienteEN = null;
                clienteEN = (ClienteEN)session.Load(typeof(ClienteEN), p_Cliente_OID);

                GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN mascotaENAux = null;
                if (clienteEN.Mascota != null)
                {
                    foreach (int item in p_mascota_OIDs)
                    {
                        mascotaENAux = (GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN)session.Load(typeof(GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN), item);
                        if (clienteEN.Mascota.Contains(mascotaENAux) == true)
                        {
                            clienteEN.Mascota.Remove(mascotaENAux);
                            mascotaENAux.Cliente = null;
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_mascota_OIDs you are trying to unrelationer, doesn't exist in ClienteEN");
                        }
                    }
                }

                session.Update(clienteEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is GestionVeterinariaGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new GestionVeterinariaGenNHibernate.Exceptions.DataLayerException("Error in ClienteCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
示例#2
0
        public void AnyadirMascota(string p_Cliente_OID, System.Collections.Generic.IList <int> p_mascota_OIDs)
        {
            GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.ClienteEN clienteEN = null;
            try
            {
                SessionInitializeTransaction();
                clienteEN = (ClienteEN)session.Load(typeof(ClienteEN), p_Cliente_OID);
                GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN mascotaENAux = null;
                if (clienteEN.Mascota == null)
                {
                    clienteEN.Mascota = new System.Collections.Generic.List <GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN>();
                }

                foreach (int item in p_mascota_OIDs)
                {
                    mascotaENAux         = new GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN();
                    mascotaENAux         = (GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN)session.Load(typeof(GestionVeterinariaGenNHibernate.EN.GestionVeterinaria.MascotaEN), item);
                    mascotaENAux.Cliente = clienteEN;

                    clienteEN.Mascota.Add(mascotaENAux);
                }


                session.Update(clienteEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is GestionVeterinariaGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new GestionVeterinariaGenNHibernate.Exceptions.DataLayerException("Error in ClienteCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
示例#3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            MascotaEN t = obj as MascotaEN;

            if (t == null)
            {
                return(false);
            }
            if (IdMascota.Equals(t.IdMascota))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
 public MascotaEN(MascotaEN mascota)
 {
     this.init(mascota.IdMascota, mascota.Nombre, mascota.Raza, mascota.Sexo, mascota.Peso, mascota.Especie, mascota.FNacimiento, mascota.Tamanyo, mascota.Cliente, mascota.Consulta, mascota.Color, mascota.Microchip);
 }