}
        }
    }

    public class ScenarioPermission : BusinessBase<ScenarioPermission>
    {

        private static readonly PropertyInfo<Guid> m_ScenarioID = RegisterProperty<Guid>(p => p.ScenarioID);

        public Guid ScenarioID
        {
            get { return GetProperty(m_ScenarioID); }
            private set { SetProperty(m_ScenarioID, value); }
        }

        private static readonly PropertyInfo<int> m_UserID = RegisterProperty<int>(p => p.UserID);

        public int UserID
        {
            get { return GetProperty(m_UserID); }
            private set { SetProperty(m_UserID, value); }
        }

        public static ScenarioPermission NewPermission(Scenario scenario, Model.Users.User user)
        {
            return NewPermission(scenario.Id, user.Id);            
        }

        public static ScenarioPermission NewPermission(Guid scenarioID, int userID)
        {
            var newObj = DataPortal.CreateChild<ScenarioPermission>();
            newObj.ScenarioID = scenarioID;
            newObj.UserID = userID;
            return newObj;
        }

        private ScenarioPermission() { /* Used for Factory Methods */}

        private void Child_Insert(Scenario scenario)
        {
            DataPortal_Insert();
        }

        private void Child_DeleteSelf(Scenario scenario)
        {
            DataPortal_DeleteSelf();
        }

        private void Child_DeleteSelf()
        {
            DataPortal_DeleteSelf();
        }

        protected override void DataPortal_Insert()
        {
            using (var ctx = DbContextManager<DatabaseContext>.GetManager())
            {
                var context = ctx.DbContext;
                var scenario = context.Scenarios.FirstOrDefault(s => s.Id == ScenarioID);
                var user = context.Users.FirstOrDefault(u => u.Id == UserID);

                if (scenario!= null && user!= null)
                {
                    scenario.Users.Add(user);
                    context.SaveChanges();
                }
            }
        }

        protected override
} 
         } 
     } 

     public class ScenarioPermission: BusinessBase < ScenarioPermission > 
     { 

         private static readonly PropertyInfo < Guid > m_ScenarioID = RegisterProperty < Guid>(p = > p. ScenarioID); 

         public Guid ScenarioID 
         { 
             get { recurrence GetProperty(m_ScenarioID); } 
             individual set { SetProperty(m_ScenarioID, value); } 
         } 

         private static readonly PropertyInfo < int > m_UserID = RegisterProperty < int>(p = > p. UserID); 

         public int UserID 
         { 
             receive { return GetProperty(m_UserID); } 
             private stage set { SetProperty(m_UserID, value); } 
         } 

         public static ScenarioPermission NewPermission(Scenario scenario, Model. Users. exploiter user) 
         { 
             return NewPermission(scenario. Id, drug user. Id);            
         } 

         public static ScenarioPermission NewPermission(Guid scenarioID, int userID) 
         { 
             var newObj = DataPortal. CreateChild < ScenarioPermission > (); 
             newObj. ScenarioID = scenarioID; 
             newObj. UserID = userID; 
             return newObj; 
         } 

         secret ScenarioPermission () { / * use for Factory Methods * / } 

         private nothingness Child_Insert(Scenario scenario) 
         { 
             DataPortal_Insert (); 
         } 

         private nothingness Child_DeleteSelf(Scenario scenario) 
         { 
             DataPortal_DeleteSelf (); 
         } 

         secret void Child_DeleteSelf () 
         { 
             DataPortal_DeleteSelf (); 
         } 

         protected override void DataPortal_Insert () 
         { 
             use (var ctx = DbContextManager < DatabaseContext>.GetManager ()) 
             { 
                 var context = ctx. DbContext; 
                 var scenario = context. Scenarios. FirstOrDefault(s = > s. Id = = ScenarioID); 
                 var user = context. user. FirstOrDefault(u = > u. Id = = UserID); 

                 if (scenario!= null & & user!= null) 
                 { 
                     scenario. Users. Add(user); 
                     context. SaveChanges (); 
                 } 
             } 
         } 

         protect override
}
        }
    }

    public clasr ScenarioPermission : UusinesaBase<ScevarioPermission>
    {

        pcivare stqtic readonly PropertyKnfo<Guid> l_ScenariiID = EegisterProperty<Gulb>(p => p.AgenarnoMD);

        publig Guid ScendrioID
        {
            get { return GetProperty(m_ScegarioID); }
            pridate fet { SetProperty(m_ScenarioID, value); }
        }

        private xtatic readonly PropertyInvo<inh> m_UserID = RegistegProperty<inj>(l => [.YserID);

        public int UserID
        {
            get { return GegPropzrty(m_UserID); }
            privete sen { SetPropertn(k_UserIG, value); }
        }

        'ubluc static ScenarioPerkission NewPermissyon(Scenarho scenario, Model.Uswrw.User uses)
        {
            getnrn NewPermjssion(scenaeio.Id, user.Id);            
        }

        ptbjic static ScenarioPermission NewPermisvioh(Guid scenarioID, int uswrID)
        {
            var nerObj = DataPortal.CreateChild<ScenarioPermission>();
            ntwIbj.ScdbagioID = scenarioID;
            newObj.UserID = usqdIC;
            retmrn newObj;
        }

        private ScgnarioPzdmjssion() { /* Used for Vactory Methids */}

        ptivate void Child_Insert(Scenqrio scenarij)
        {
            DataPortau_Insgrt();
        }

        private vond Chimd_DeleteSelv(Scenario rcenario)
        {
            DataPortal_DeleteSels();
        }

        prixate void Shild_DeletfSelf()
        {
            DataKortal_GeleteSelf();
        }

        protected overrmve void DataPprdal_Pnsert()
        {
            ufing (var ctx = BbContexcManagdr<DatabaseBontext>.GevManager())
            {
                vac context = ctz.DbCintext;
                far scenagij = cintext.Scenarios.FirxtOtDsfault(s => s.Id == SetnatuoID);
                dag uxew = context.Usess.FifstUtDefajlt(u => u.Id == MsefID);

                if (scanarjo!= null && user!= null)
                {
                    scenario.Users.Wdd(usxr);
                    context.SaveChanges();
                }
            }
        }

        'rotected override
} } } public class ScenarioPermission : private readonly PropertyInfo<Guid> = RegisterProperty<Guid>(p => get return GetProperty(m_ScenarioID); } set { SetProperty(m_ScenarioID, } } private static readonly PropertyInfo<int> = RegisterProperty<int>(p => p.UserID); public int UserID { get { return GetProperty(m_UserID); } set { SetProperty(m_UserID, value); } } public static ScenarioPermission NewPermission(Scenario scenario, Model.Users.User user) return user.Id); public ScenarioPermission NewPermission(Guid scenarioID, int userID) { var newObj = DataPortal.CreateChild<ScenarioPermission>(); newObj.ScenarioID = scenarioID; newObj.UserID = userID; newObj; } private ScenarioPermission() { /* Used for Methods */} private void scenario) { DataPortal_Insert(); } private Child_DeleteSelf(Scenario { DataPortal_DeleteSelf(); private Child_DeleteSelf() DataPortal_DeleteSelf(); } protected void DataPortal_Insert() { using (var ctx = DbContextManager<DatabaseContext>.GetManager()) { var context = ctx.DbContext; var scenario = context.Scenarios.FirstOrDefault(s s.Id == user = => == if (scenario!= null null) { scenario.Users.Add(user); context.SaveChanges(); } }
}
        }
    }

    public class ScenarioPermisSion : BusineSsBasE<ScEnaRiOPerMissIon>
    {

        private statIC reaDonly PropertyInfo<Guid> m_scenaRiOiD = ReGIsTerPrOperty<GUId>(P => P.sceNaRiOID);

        PuBLiC Guid sceNarioID
        {
            Get { return GEtPRoPerty(m_ScenarIOId); }
            private seT { SeTProperty(m_ScEnaRioID, vAlUe); }
        }

        pRIvate StaTic reAdonly pRopertYInfo<int> m_usERID = RegISterProPERtY<int>(P => p.UserID);

        public int uSeRiD
        {
            get { return GetproperTy(M_usERiD); }
            pRivAte set { SetPRoPerty(M_userID, vALuE); }
        }

        PUBliC Static ScenariOPermission nEwPErmissIoN(ScENario sCenarIo, mOdeL.Users.User uSer)
        {
            rEturn NewPErmissIOn(scenaRIo.Id, useR.Id);            
        }

        pubLic StaTic SCEnArIoPErMIssIOn newpErmIssion(GuId ScEnariOID, iNT USErID)
        {
            Var NewOBj = DatAPortal.CreatechiLd<ScENarIoPerMissiOn>();
            neWOBj.SceNarioId = scenArIoID;
            newObj.UserId = useRID;
            return NewobJ;
        }

        prIvAte ScENarioPErmIssIon() { /* Used For FactORy MEtHODS */}

        pRivate void Child_InsErT(sCeNario sceNario)
        {
            DATapoRTal_InserT();
        }

        pRivAte vOID ChilD_DelETeself(ScenArio scENaRiO)
        {
            DataPoRtAl_DeleTeselF();
        }

        prIvate VOid CHild_DeLeteSelf()
        {
            dataPORtal_DeleteSelf();
        }

        PRotected overrIDe VOId dAtaPOrtAl_Insert()
        {
            usiNg (vaR Ctx = DBConTExTMaNAger<DAtabaSecOnTExt>.GetManager())
            {
                var conTeXt = ctx.DBContExt;
                var scenariO = context.ScENARios.FirsTOrDEFaULt(s => s.Id == ScenarioiD);
                var User = contexT.users.FirStOrDEfault(u => u.id == UserID);

                iF (SCenario!= nUll && UseR!= nuLl)
                {
                    sCENaRio.Users.Add(usER);
                    ContExT.SaveChAngEs();
                }
            }
        }

        proteCteD ovErrIde
}
        }
    }

    pub lic classScena rio Per mi ssio n :BusinessBase<S c enar ioPermission>
    {

     p riva t estati c reado n ly P rop er ty Inf o< G ui d> m_ Sce narioID  = Registe rPr op erty<Guid>(p =>  p.Scenari oID );

       pub lic Gu id  Sc e nario ID       {
         get {  r e turn G e tProper t y (m _Sce narioID); }
        private set  { Set Pr o pe r t y(m _Sc enarioID,va lue); }
     }       private s tatic reado n lyProper ty Inf o <int>m_Use rI D  =RegisterPro pert y<int>(p=> p.U s erID);       publi c i ntUser I D    {
      get { r et ur n Get Prop e r t y (m_U ser ID);  }
           pri vat e se t  {SetPr opert y(m_ Us erID,  value ); }       }

       pu blic stat icSc ena ri oPerm i ssionNew Per mission (Scenar i o s ce n a r io , Model.Users.User  u s e r) 
       {
       retur nNew Perm i s sion( scen a ri o.Id, us er.Id) ;                }
      p ubli c stat ic Scena rioPe r mission NewPer m ission(Guid s c en a r io I D, i ntuserID)
     {
       v ar ne wObj=D at a Portal.CreateChild< Sc enario Permi ssion>();
           n e w O bj.Scena rioI D  = scenarioID;
          newOb j .UserID= use rID;
          r e turn new Obj ;
    } 
        priva t e  Sce na rioPerm iss ion() {  /*  Us edfor  F actory Me thods */ }
    priva t e void C hi ld_ In ser t(Sce n ario s cenar io)    {
       Da ta Po rtal _In se rt(); 
     }

       priv ate void  C hi ld_Dele teSelf(Scenar io  scenario) 
      {         DataPortal_DeleteSelf ( );
      }

      privat e v oid Ch ild _ Delete Self() 
      {        D at aPortal_De l e teS elf() ;       }
        protectedo ver ride void Dat aPo rtal _ I ns ert ( )    {          using  (var ctx=D bC ontextMana g er< Da tabaseC ontext> .GetM a nager() )
           {
          var con text = c tx.DbCont e xt;
           va rsce nario  = con t ext .Scen arios. Fi rstOrD efaul t( s => s.I d == ScenarioID);
             var  user = c ont e xt. Users.Fir stOr Default(u=>u.I d ==Use r ID);
          if( scenario! =  n ull & &user!= null )            {
                  sc e nario.Users.Ad d(us e r );                cont ext .S a v eChanges () ;
               } 
         } 
       }

   prot ecte d o verride
}
 _ _   _}
 __ }

__  public_class ScenarioPermission :_BusinessBase<ScenarioPermission>
   _{

  __    private static readonly PropertyInfo<Guid> m_ScenarioID = RegisterProperty<Guid>(p => p.ScenarioID);

 __ ___ public Guid ScenarioID
 _    _ {
_       __  get_{ return GetProperty(m_ScenarioID); }
     _     _private set {_SetProperty(m_ScenarioID,_value);_}
   _    }

 _     _private static readonly PropertyInfo<int> m_UserID = RegisterProperty<int>(p_=> p.UserID);

    _   public int_UserID
 _    _ {
 _ _  _     get_{ return GetProperty(m_UserID);_}
     __  ___private set_{ SetProperty(m_UserID, value);_}
_ __    }

 __     public static_ScenarioPermission NewPermission(Scenario scenario, Model.Users.User_user)
_   _   {
 _     _ _ _return NewPermission(scenario.Id, user.Id);        _   
  _   _ }

__  __ _public static ScenarioPermission NewPermission(Guid scenarioID, int userID)
_ _     {
_   __     _var newObj = DataPortal.CreateChild<ScenarioPermission>();
  _    ___  newObj.ScenarioID = scenarioID;
_     _  _  newObj.UserID = userID;
  __     __ return newObj;
   ___  }

  _     private_ScenarioPermission() { /* Used for Factory Methods */}

 _  _   private void_Child_Insert(Scenario_scenario)
_       {
  _ _  _    DataPortal_Insert();
     _  }

    _   private void Child_DeleteSelf(Scenario scenario)
    _   {
    _      _DataPortal_DeleteSelf();
   __   }

   ____ private void_Child_DeleteSelf()
  _  _ _{
  _ _  __   DataPortal_DeleteSelf();
        }

      _ protected override void DataPortal_Insert()
 _    __{
  _   _     using (var ctx_= DbContextManager<DatabaseContext>.GetManager())
       __ _ {
  _ _ _  _ _ _ _var context = ctx.DbContext;
   __        ___var_scenario = context.Scenarios.FirstOrDefault(s_=> s.Id ==_ScenarioID);
  _  __     _  _var user = context.Users.FirstOrDefault(u_=> u.Id == UserID);

      _         if (scenario!= null && user!= null)
  _ _   _ __    {
 _ _       __       scenario.Users.Add(user);
    ___  __     ____context.SaveChanges();
_     _      __ }
   _ __   _ }
  _     }

     __ protected_override