Exemple #1
0
        /// <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.DataAccessLayerMessageOfEntityCollectionElmahApplication> Upsert(Elmah.DataSourceEntities.ElmahApplication input)
        {
            //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            var _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahApplication();

            _retval.OriginalValue = new List <Elmah.DataSourceEntities.ElmahApplication>();
            _retval.OriginalValue.Add(input);

            if (input != null)
            {
                var _LinqItem = await GetLinqObjectByIdentifier(input);

                if (_LinqItem == null)
                {
                    _LinqItem = input.GetAClone <Elmah.EntityFrameworkContext.ElmahApplication>();
                    LinqContext.ElmahApplication.Add(_LinqItem);
                }
                else
                {
                    input.CopyTo <Elmah.EntityFrameworkContext.ElmahApplication>(_LinqItem);
                }

                await this.LinqContext.SaveChangesAsync();

                Elmah.DataSourceEntities.ElmahApplication _Result = new Elmah.DataSourceEntities.ElmahApplication();
                _Result.CopyFrom <Elmah.EntityFrameworkContext.ElmahApplication>(_LinqItem);
                _retval.Result = new List <Elmah.DataSourceEntities.ElmahApplication>();
                _retval.Result.Add(_Result);
            }
            //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            return(_retval);
        }
Exemple #2
0
        /// <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.DataAccessLayerMessageOfEntityCollectionElmahApplication> DeleteByIdentifier(Elmah.DataSourceEntities.ElmahApplicationIdentifier id)
        {
            //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

            Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahApplication _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahApplication();

            if (id != null)
            {
                Elmah.EntityFrameworkContext.ElmahApplication _LinqItem = await GetLinqObjectByIdentifier(id);

                if (_LinqItem != null)
                {
                    Elmah.DataSourceEntities.ElmahApplication _Original = new Elmah.DataSourceEntities.ElmahApplication();
                    _Original.CopyFrom <Elmah.EntityFrameworkContext.ElmahApplication>(_LinqItem);

                    _retval.OriginalValue = new List <Elmah.DataSourceEntities.ElmahApplication>();
                    _retval.OriginalValue.Add(_Original);

                    this.LinqContext.ElmahApplication.Remove(_LinqItem);
                    await this.LinqContext.SaveChangesAsync();
                }
            }
            //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString()));
            return(_retval);
        }