public void UnassignGoal(int p_CarePlan_OID, System.Collections.Generic.IList <int> p_goal_OIDs)
        {
            try
            {
                SessionInitializeTransaction();
                ChroniGenNHibernate.EN.Chroni.CarePlanEN carePlanEN = null;
                carePlanEN = (CarePlanEN)session.Load(typeof(CarePlanEN), p_CarePlan_OID);

                ChroniGenNHibernate.EN.Chroni.GoalEN goalENAux = null;
                if (carePlanEN.Goal != null)
                {
                    foreach (int item in p_goal_OIDs)
                    {
                        goalENAux = (ChroniGenNHibernate.EN.Chroni.GoalEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.GoalEN), item);
                        if (carePlanEN.Goal.Contains(goalENAux) == true)
                        {
                            carePlanEN.Goal.Remove(goalENAux);
                            goalENAux.CarePlan = null;
                        }
                        else
                        {
                            throw new ModelException("The identifier " + item + " in p_goal_OIDs you are trying to unrelationer, doesn't exist in CarePlanEN");
                        }
                    }
                }

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

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


            finally
            {
                SessionClose();
            }
        }
        public void AssignGoal(int p_CarePlan_OID, System.Collections.Generic.IList <int> p_goal_OIDs)
        {
            ChroniGenNHibernate.EN.Chroni.CarePlanEN carePlanEN = null;
            try
            {
                SessionInitializeTransaction();
                carePlanEN = (CarePlanEN)session.Load(typeof(CarePlanEN), p_CarePlan_OID);
                ChroniGenNHibernate.EN.Chroni.GoalEN goalENAux = null;
                if (carePlanEN.Goal == null)
                {
                    carePlanEN.Goal = new System.Collections.Generic.List <ChroniGenNHibernate.EN.Chroni.GoalEN>();
                }

                foreach (int item in p_goal_OIDs)
                {
                    goalENAux          = new ChroniGenNHibernate.EN.Chroni.GoalEN();
                    goalENAux          = (ChroniGenNHibernate.EN.Chroni.GoalEN)session.Load(typeof(ChroniGenNHibernate.EN.Chroni.GoalEN), item);
                    goalENAux.CarePlan = carePlanEN;

                    carePlanEN.Goal.Add(goalENAux);
                }


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

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


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

            if (t == null)
            {
                return(false);
            }
            if (Identifier.Equals(t.Identifier))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
 public GoalEN(GoalEN goal)
 {
     this.init(Identifier, goal.Subject, goal.StatusDate, goal.Target, goal.Category, goal.Description, goal.Status, goal.Priority, goal.Note, goal.CarePlan);
 }