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