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.Currency obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.Currency obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.Currency SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.Currency properties Indico.DAL.Currency obj = new Indico.DAL.Currency(); if (this.ID > 0) { obj = context.Currency.FirstOrDefault <Currency>(o => o.ID == this.ID); } obj.Code = this.Code; obj.Country = this.Country; obj.Name = this.Name; obj.Symbol = this.Symbol; if (_fabricCodesWhereThisIsLandedCurrencyLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.FabricCodeBO.ToEntityList(this.FabricCodesWhereThisIsLandedCurrency, context), obj.FabricCodesWhereThisIsLandedCurrency); } if (_quotesWhereThisIsCurrencyLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.QuoteBO.ToEntityList(this.QuotesWhereThisIsCurrency, context), obj.QuotesWhereThisIsCurrency); } this._doNotUpdateDALObject = false; return(obj); }
public void Add() { if (this.Context != null) { this.Context.Context.AddToCurrency(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.Currency obj = this.SetDAL(objContext.Context); objContext.Context.AddToCurrency(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the CurrencyBO class using the supplied Indico.DAL.Currency. /// </summary> /// <param name="obj">a Indico.DAL.Currency whose properties will be used to initialise the CurrencyBO</param> internal CurrencyBO(Indico.DAL.Currency obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.Currency this.ID = obj.ID; this.Code = obj.Code; this.Country = obj.Country; this.Name = obj.Name; this.Symbol = obj.Symbol; 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.Currency)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.Currency obj = (Indico.DAL.Currency)eObj; // set the Indico.BusinessObjects.CurrencyBO properties this.ID = obj.ID; this.Code = obj.Code; this.Country = obj.Country; this.Name = obj.Name; this.Symbol = obj.Symbol; this._doNotUpdateDALObject = false; }