/// <summary> /// single item insert/update with entity input /// </summary> /// <param name="input">to-be-insert/updated instance of entity class</param> public async Task <Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahHost> Upsert(Elmah.DataSourceEntities.ElmahHost input) { //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); var _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahHost(); _retval.OriginalValue = new List <Elmah.DataSourceEntities.ElmahHost>(); _retval.OriginalValue.Add(input); if (input != null) { var _LinqItem = await GetLinqObjectByIdentifier(input); if (_LinqItem == null) { _LinqItem = input.GetAClone <Elmah.EntityFrameworkContext.ElmahHost>(); LinqContext.ElmahHost.Add(_LinqItem); } else { input.CopyTo <Elmah.EntityFrameworkContext.ElmahHost>(_LinqItem); } await this.LinqContext.SaveChangesAsync(); Elmah.DataSourceEntities.ElmahHost _Result = new Elmah.DataSourceEntities.ElmahHost(); _Result.CopyFrom <Elmah.EntityFrameworkContext.ElmahHost>(_LinqItem); _retval.Result = new List <Elmah.DataSourceEntities.ElmahHost>(); _retval.Result.Add(_Result); } //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); return(_retval); }
/// <summary> /// single item delete by identifier with entity identifier input /// </summary> /// <param name="id">delete the item if its identifier equals to this parameter</param> public async Task <Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahHost> DeleteByIdentifier(Elmah.DataSourceEntities.ElmahHostIdentifier id) { //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahHost _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahHost(); if (id != null) { Elmah.EntityFrameworkContext.ElmahHost _LinqItem = await GetLinqObjectByIdentifier(id); if (_LinqItem != null) { Elmah.DataSourceEntities.ElmahHost _Original = new Elmah.DataSourceEntities.ElmahHost(); _Original.CopyFrom <Elmah.EntityFrameworkContext.ElmahHost>(_LinqItem); _retval.OriginalValue = new List <Elmah.DataSourceEntities.ElmahHost>(); _retval.OriginalValue.Add(_Original); this.LinqContext.ElmahHost.Remove(_LinqItem); await this.LinqContext.SaveChangesAsync(); } } //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return(_retval); }