Exemplo n.º 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.DataAccessLayerMessageOfEntityCollectionElmahType> Upsert(Elmah.DataSourceEntities.ElmahType input)
        {
            //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            var _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahType();

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

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

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

                await this.LinqContext.SaveChangesAsync();

                Elmah.DataSourceEntities.ElmahType _Result = new Elmah.DataSourceEntities.ElmahType();
                _Result.CopyFrom <Elmah.EntityFrameworkContext.ElmahType>(_LinqItem);
                _retval.Result = new List <Elmah.DataSourceEntities.ElmahType>();
                _retval.Result.Add(_Result);
            }
            //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            return(_retval);
        }
Exemplo n.º 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.DataAccessLayerMessageOfEntityCollectionElmahType> DeleteByIdentifier(Elmah.DataSourceEntities.ElmahTypeIdentifier id)
        {
            //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

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

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

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

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

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