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.OrderDetailStatus obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.OrderDetailStatus obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.OrderDetailStatus)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.OrderDetailStatus obj = (Indico.DAL.OrderDetailStatus)eObj; // set the Indico.BusinessObjects.OrderDetailStatusBO properties this.ID = obj.ID; this.Description = obj.Description; this.Name = obj.Name; this.Priority = obj.Priority; this.Company = (obj.CompanyReference.EntityKey != null && obj.CompanyReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CompanyReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToOrderDetailStatus(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.OrderDetailStatus obj = this.SetDAL(objContext.Context); objContext.Context.AddToOrderDetailStatus(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the OrderDetailStatusBO class using the supplied Indico.DAL.OrderDetailStatus. /// </summary> /// <param name="obj">a Indico.DAL.OrderDetailStatus whose properties will be used to initialise the OrderDetailStatusBO</param> internal OrderDetailStatusBO(Indico.DAL.OrderDetailStatus obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.OrderDetailStatus this.ID = obj.ID; this.Company = (obj.CompanyReference.EntityKey != null && obj.CompanyReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CompanyReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Description = obj.Description; this.Name = obj.Name; this.Priority = obj.Priority; this._doNotUpdateDALObject = false; }
internal Indico.DAL.OrderDetailStatus SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.OrderDetailStatus properties Indico.DAL.OrderDetailStatus obj = new Indico.DAL.OrderDetailStatus(); if (this.ID > 0) { obj = context.OrderDetailStatus.FirstOrDefault <OrderDetailStatus>(o => o.ID == this.ID); } obj.Description = this.Description; obj.Name = this.Name; obj.Priority = this.Priority; if (this.Company != null && this.Company > 0) { obj.Company = context.Company.FirstOrDefault(o => o.ID == this.Company); } if (_factoryOrderDetialsWhereThisIsOrderDetailStatusLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.FactoryOrderDetialBO.ToEntityList(this.FactoryOrderDetialsWhereThisIsOrderDetailStatus, context), obj.FactoryOrderDetialsWhereThisIsOrderDetailStatus); } if (_orderDetailsWhereThisIsStatusLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.OrderDetailBO.ToEntityList(this.OrderDetailsWhereThisIsStatus, context), obj.OrderDetailsWhereThisIsStatus); } this._doNotUpdateDALObject = false; return(obj); }