Example #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);
        }
        /// <summary>
        /// Gets the collection of entity of EntityByIdentifier .
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>an instance of Elmah.CommonBLLEntities.ElmahApplicationResponseMessageBuiltIn if any</returns>
        public async Task <Elmah.CommonBLLEntities.ElmahApplicationResponseMessageBuiltIn> GetCollectionOfEntityByIdentifier(
            Elmah.CommonBLLEntities.ElmahApplicationRequestMessageUserDefinedOfIdentifier request)
        {
            //log.Info(string.Format("{0}: GetCollectionOfEntityByIdentifier", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Started.ToString()));

            if (!request.Criteria.CanQueryWhenNoQuery && !request.Criteria.HasQuery)
            {
                var failedResponse = new Elmah.CommonBLLEntities.ElmahApplicationResponseMessageBuiltIn();
                failedResponse.BusinessLogicLayerResponseStatus = Framework.Services.BusinessLogicLayerResponseStatus.NeedAtLeastOneSearchCondition;
                failedResponse.ServerErrorMessage = "Please enter at least one search condition";
                return(failedResponse);
            }

            Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahApplication _resultFromDAL = await this.DALClassInstance.GetCollectionOfEntityByIdentifier(
                request.Criteria.Identifier.Application
                , request.QueryPagingSetting.CurrentIndex
                , request.QueryPagingSetting.PageSize
                , request.QueryOrderBySettingCollection
                );

            Elmah.CommonBLLEntities.ElmahApplicationResponseMessageBuiltIn _retval = new Elmah.CommonBLLEntities.ElmahApplicationResponseMessageBuiltIn();
            _retval.BusinessLogicLayerRequestID = request.BusinessLogicLayerRequestID;

            //Framework.Services.BusinessLogicLayerResponseMessageBaseHelper.MapDataAccessLayerMessageToBusinessLogicLayerResponseMessage<List<Elmah.DataSourceEntities.ElmahApplication>>(_resultFromDAL, _retval);

            if (request.DataServiceType == Framework.Models.DataServiceTypes.DataSourceResult)
            {
                Framework.Services.BusinessLogicLayerResponseMessageBaseHelper.MapDataAccessLayerMessageToBusinessLogicLayerResponseMessage <List <Elmah.DataSourceEntities.ElmahApplication> >(_resultFromDAL, _retval);
            }
            else
            {
                Framework.Services.BusinessLogicLayerResponseMessageBaseHelper.MapDataAccessLayerMessageToBusinessLogicLayerResponseMessage <Elmah.DataSourceEntities.ElmahApplication, List <Elmah.DataSourceEntities.ElmahApplication> >(_resultFromDAL, _retval, request.DataServiceType, new Elmah.CoreCommonBLL.ElmahApplicationDataStreamService());
            }

            //log.Info(string.Format("{0}: GetCollectionOfEntityByIdentifier", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Ended.ToString()));
            return(_retval);
        }
Example #3
0
        /// <summary>
        /// single item deletion with entity input
        /// </summary>
        /// <param name="input">item to be deleted</param>
        public async Task <Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahApplication> Delete(Elmah.DataSourceEntities.ElmahApplication input)
        {
            //log.Info(string.Format("{0}: Delete", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

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

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

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