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.CoordinatorEmailAddress obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.CoordinatorEmailAddress obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
public void Add() { if (this.Context != null) { this.Context.Context.AddToCoordinatorEmailAddress(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.CoordinatorEmailAddress obj = this.SetDAL(objContext.Context); objContext.Context.AddToCoordinatorEmailAddress(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the CoordinatorEmailAddressBO class using the supplied Indico.DAL.CoordinatorEmailAddress. /// </summary> /// <param name="obj">a Indico.DAL.CoordinatorEmailAddress whose properties will be used to initialise the CoordinatorEmailAddressBO</param> internal CoordinatorEmailAddressBO(Indico.DAL.CoordinatorEmailAddress obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.CoordinatorEmailAddress this.ID = obj.ID; this.EmailAddress = obj.EmailAddress; 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; }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.CoordinatorEmailAddress)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.CoordinatorEmailAddress obj = (Indico.DAL.CoordinatorEmailAddress)eObj; // set the Indico.BusinessObjects.CoordinatorEmailAddressBO properties this.ID = obj.ID; this.EmailAddress = obj.EmailAddress; 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; }
internal Indico.DAL.CoordinatorEmailAddress SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.CoordinatorEmailAddress properties Indico.DAL.CoordinatorEmailAddress obj = new Indico.DAL.CoordinatorEmailAddress(); if (this.ID > 0) { obj = context.CoordinatorEmailAddress.FirstOrDefault <CoordinatorEmailAddress>(o => o.ID == this.ID); } obj.EmailAddress = this.EmailAddress; if (this.User > 0) { obj.User = context.User.FirstOrDefault(o => o.ID == this.User); } this._doNotUpdateDALObject = false; return(obj); }