예제 #1
0
        public int New_(int p_notification, string p_user, bool p_isReceived)
        {
            NotificationUserEN notificationUserEN = null;
            int oid;

            //Initialized NotificationUserEN
            notificationUserEN = new NotificationUserEN();

            if (p_notification != -1)
            {
                // El argumento p_notification -> Property notification es oid = false
                // Lista de oids id
                notificationUserEN.Notification    = new MoSIoTGenNHibernate.EN.MosIoT.NotificationEN();
                notificationUserEN.Notification.Id = p_notification;
            }


            if (p_user != null)
            {
                // El argumento p_user -> Property user es oid = false
                // Lista de oids id
                notificationUserEN.User       = new MoSIoTGenNHibernate.EN.MosIoT.UserEN();
                notificationUserEN.User.Email = p_user;
            }

            notificationUserEN.IsReceived = p_isReceived;

            //Call to NotificationUserCAD

            oid = _INotificationUserCAD.New_(notificationUserEN);
            return(oid);
        }
// Modify default (Update all attributes of the class)

        public void ModifyDefault(NotificationUserEN notificationUser)
        {
            try
            {
                SessionInitializeTransaction();
                NotificationUserEN notificationUserEN = (NotificationUserEN)session.Load(typeof(NotificationUserEN), notificationUser.Id);



                notificationUserEN.IsReceived = notificationUser.IsReceived;

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

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


            finally
            {
                SessionClose();
            }
        }
        public NotificationUserEN ReadOIDDefault(int id
                                                 )
        {
            NotificationUserEN notificationUserEN = null;

            try
            {
                SessionInitializeTransaction();
                notificationUserEN = (NotificationUserEN)session.Get(typeof(NotificationUserEN), id);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(notificationUserEN);
        }
        public void Destroy(int id
                            )
        {
            try
            {
                SessionInitializeTransaction();
                NotificationUserEN notificationUserEN = (NotificationUserEN)session.Load(typeof(NotificationUserEN), id);
                session.Delete(notificationUserEN);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }
        }
        public static NotificationUserEN Convert(NotificationUserDTO dto)
        {
            NotificationUserEN newinstance = null;

            try
            {
                if (dto != null)
                {
                    newinstance = new NotificationUserEN();



                    if (dto.Notification_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.INotificationCAD notificationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.NotificationCAD();

                        newinstance.Notification = notificationCAD.ReadOIDDefault(dto.Notification_oid);
                    }
                    newinstance.Id = dto.Id;
                    if (dto.User_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IUserCAD userCAD = new MoSIoTGenNHibernate.CAD.MosIoT.UserCAD();

                        newinstance.User = userCAD.ReadOIDDefault(dto.User_oid);
                    }
                    newinstance.IsReceived = dto.IsReceived;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }
예제 #6
0
        public void Modify(int p_NotificationUser_OID, bool p_isReceived)
        {
            NotificationUserEN notificationUserEN = null;

            //Initialized NotificationUserEN
            notificationUserEN            = new NotificationUserEN();
            notificationUserEN.Id         = p_NotificationUser_OID;
            notificationUserEN.IsReceived = p_isReceived;
            //Call to NotificationUserCAD

            _INotificationUserCAD.Modify(notificationUserEN);
        }
        public int New_(NotificationUserEN notificationUser)
        {
            try
            {
                SessionInitializeTransaction();
                if (notificationUser.Notification != null)
                {
                    // Argumento OID y no colección.
                    notificationUser.Notification = (MoSIoTGenNHibernate.EN.MosIoT.NotificationEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.NotificationEN), notificationUser.Notification.Id);

                    notificationUser.Notification.NotificationUSer
                    .Add(notificationUser);
                }
                if (notificationUser.User != null)
                {
                    // Argumento OID y no colección.
                    notificationUser.User = (MoSIoTGenNHibernate.EN.MosIoT.UserEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.UserEN), notificationUser.User.Email);

                    notificationUser.User.NotificationUSer
                    .Add(notificationUser);
                }

                session.Save(notificationUser);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(notificationUser.Id);
        }