Ejemplo n.º 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.PrinterType obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext          objContext = new IndicoContext();
         Indico.DAL.PrinterType obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Ejemplo n.º 2
0
        internal Indico.DAL.PrinterType SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.Name   = this.Name;
            obj.Prefix = this.Prefix;


            if (_patternsWhereThisIsPrinterTypeLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.PatternBO.ToEntityList(this.PatternsWhereThisIsPrinterType, context),
                    obj.PatternsWhereThisIsPrinterType);
            }

            this._doNotUpdateDALObject = false;

            return(obj);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an instance of the PrinterTypeBO class using the supplied Indico.DAL.PrinterType.
        /// </summary>
        /// <param name="obj">a Indico.DAL.PrinterType whose properties will be used to initialise the PrinterTypeBO</param>
        internal PrinterTypeBO(Indico.DAL.PrinterType obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.Name   = obj.Name;
            this.Prefix = obj.Prefix;

            this._doNotUpdateDALObject = false;
        }
Ejemplo n.º 4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToPrinterType(this.ObjDAL);
     }
     else
     {
         IndicoContext          objContext = new IndicoContext();
         Indico.DAL.PrinterType obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToPrinterType(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Ejemplo n.º 5
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

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

            this.Name   = obj.Name;
            this.Prefix = obj.Prefix;


            this._doNotUpdateDALObject = false;
        }