public void UnassignMedication(int p_Activity_OID, System.Collections.Generic.IList <int> p_medication_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.ActivityEN activityEN = null;
                activityEN = (ActivityEN)session.Load(typeof(ActivityEN), p_Activity_OID);

                ChroniGenNHibernate.EN.Chroni.MedicationEN medicationENAux = null;
                if (activityEN.Medication != null)
                {
                    foreach (int item in p_medication_OIDs)
                    {
                        medicationENAux = (ChroniGenNHibernate.EN.Chroni.MedicationEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.MedicationEN), item);
                        if (activityEN.Medication.Contains(medicationENAux) == true)
                        {
                            activityEN.Medication.Remove(medicationENAux);
                            medicationENAux.Activity.Remove(activityEN);
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_medication_OIDs you are trying to unrelationer, doesn't exist in ActivityEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
        public void AssignMedication(int p_Activity_OID, System.Collections.Generic.IList <int> p_medication_OIDs)
        {
            ChroniGenNHibernate.EN.Chroni.ActivityEN activityEN = null;
            try
            {
                SessionInitializeTransaction();
                activityEN = (ActivityEN)session.Load(typeof(ActivityEN), p_Activity_OID);
                ChroniGenNHibernate.EN.Chroni.MedicationEN medicationENAux = null;
                if (activityEN.Medication == null)
                {
                    activityEN.Medication = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.MedicationEN>();
                }

                foreach (int item in p_medication_OIDs)
                {
                    medicationENAux = new ChroniGenNHibernate.EN.Chroni.MedicationEN();
                    medicationENAux = (ChroniGenNHibernate.EN.Chroni.MedicationEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.MedicationEN), item);
                    medicationENAux.Activity.Add(activityEN);

                    activityEN.Medication.Add(medicationENAux);
                }


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

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


            finally
            {
                SessionClose();
            }
        }
Пример #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            MedicationEN t = obj as MedicationEN;

            if (t == null)
            {
                return(false);
            }
            if (Identifier.Equals(t.Identifier))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
 public MedicationEN(MedicationEN medication)
 {
     this.init(Identifier, medication.Name, medication.Manufacturer, medication.Description, medication.Form, medication.Rate, medication.Dosage, medication.Status, medication.IsOverTheCounter, medication.Ingredient, medication.Activity);
 }