Пример #1
0
 public void Delete()
 {
     if (this.Context != null)
     {
         if (this.ObjDAL != null && this.ObjDAL.EntityKey != null)
         {
             if (this.ObjDAL.EntityState == System.Data.EntityState.Detached)
             {
                 this.Context.Context.Attach(this.ObjDAL);
                 this.Context.Context.DeleteObject(this.ObjDAL);
             }
             else
             {
                 this.Context.Context.DeleteObject(this.ObjDAL);
             }
         }
         else
         {
             Indico.DAL.UserLogin obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext        objContext = new IndicoContext();
         Indico.DAL.UserLogin obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Пример #2
0
        internal Indico.DAL.UserLogin SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

            // set the Indico.DAL.UserLogin properties
            Indico.DAL.UserLogin obj = new Indico.DAL.UserLogin();

            if (this.ID > 0)
            {
                obj = context.UserLogin.FirstOrDefault <UserLogin>(o => o.ID == this.ID);
            }

            obj.DateLogin  = this.DateLogin;
            obj.DateLogout = this.DateLogout;
            obj.IpAddress  = this.IpAddress;
            obj.SessionId  = this.SessionId;
            obj.Success    = this.Success;

            if (this.User > 0)
            {
                obj.User = context.User.FirstOrDefault(o => o.ID == this.User);
            }


            this._doNotUpdateDALObject = false;

            return(obj);
        }
Пример #3
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

            // Check the received type
            if (eObj.GetType() != typeof(Indico.DAL.UserLogin))
            {
                throw new FormatException("Received wrong parameter type...");
            }

            Indico.DAL.UserLogin obj = (Indico.DAL.UserLogin)eObj;

            // set the Indico.BusinessObjects.UserLoginBO properties
            this.ID = obj.ID;

            this.DateLogin  = obj.DateLogin;
            this.DateLogout = obj.DateLogout;
            this.IpAddress  = obj.IpAddress;
            this.SessionId  = obj.SessionId;
            this.Success    = obj.Success;

            this.User = (obj.UserReference.EntityKey != null && obj.UserReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.UserReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Пример #4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToUserLogin(this.ObjDAL);
     }
     else
     {
         IndicoContext        objContext = new IndicoContext();
         Indico.DAL.UserLogin obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToUserLogin(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Пример #5
0
        /// <summary>
        /// Creates an instance of the UserLoginBO class using the supplied Indico.DAL.UserLogin.
        /// </summary>
        /// <param name="obj">a Indico.DAL.UserLogin whose properties will be used to initialise the UserLoginBO</param>
        internal UserLoginBO(Indico.DAL.UserLogin obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

            // set the properties from the Indico.DAL.UserLogin
            this.ID = obj.ID;

            this.DateLogin  = obj.DateLogin;
            this.DateLogout = obj.DateLogout;
            this.IpAddress  = obj.IpAddress;
            this.SessionId  = obj.SessionId;
            this.Success    = obj.Success;
            this.User       = (obj.UserReference.EntityKey != null && obj.UserReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.UserReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }