/// <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.DataAccessLayerMessageOfEntityCollectionElmahSource> Upsert(Elmah.DataSourceEntities.ElmahSource input) { //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); var _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahSource(); _retval.OriginalValue = new List <Elmah.DataSourceEntities.ElmahSource>(); _retval.OriginalValue.Add(input); if (input != null) { var _LinqItem = await GetLinqObjectByIdentifier(input); if (_LinqItem == null) { _LinqItem = input.GetAClone <Elmah.EntityFrameworkContext.ElmahSource>(); LinqContext.ElmahSource.Add(_LinqItem); } else { input.CopyTo <Elmah.EntityFrameworkContext.ElmahSource>(_LinqItem); } await this.LinqContext.SaveChangesAsync(); Elmah.DataSourceEntities.ElmahSource _Result = new Elmah.DataSourceEntities.ElmahSource(); _Result.CopyFrom <Elmah.EntityFrameworkContext.ElmahSource>(_LinqItem); _retval.Result = new List <Elmah.DataSourceEntities.ElmahSource>(); _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.DataAccessLayerMessageOfEntityCollectionElmahSource> DeleteByIdentifier(Elmah.DataSourceEntities.ElmahSourceIdentifier id) { //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString())); Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahSource _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahSource(); if (id != null) { Elmah.EntityFrameworkContext.ElmahSource _LinqItem = await GetLinqObjectByIdentifier(id); if (_LinqItem != null) { Elmah.DataSourceEntities.ElmahSource _Original = new Elmah.DataSourceEntities.ElmahSource(); _Original.CopyFrom <Elmah.EntityFrameworkContext.ElmahSource>(_LinqItem); _retval.OriginalValue = new List <Elmah.DataSourceEntities.ElmahSource>(); _retval.OriginalValue.Add(_Original); this.LinqContext.ElmahSource.Remove(_LinqItem); await this.LinqContext.SaveChangesAsync(); } } //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString())); return(_retval); }