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

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

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

            obj.Description = this.Description;
            obj.Name        = this.Name;


            if (_productsWhereThisIsPrinterLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.ProductBO.ToEntityList(this.ProductsWhereThisIsPrinter, context),
                    obj.ProductsWhereThisIsPrinter);
            }
            if (_visualLayoutsWhereThisIsPrinterLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.VisualLayoutBO.ToEntityList(this.VisualLayoutsWhereThisIsPrinter, context),
                    obj.VisualLayoutsWhereThisIsPrinter);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.Description = obj.Description;
            this.Name        = obj.Name;

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

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

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

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

            this.Description = obj.Description;
            this.Name        = obj.Name;


            this._doNotUpdateDALObject = false;
        }