コード例 #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.DataAccessLayerMessageOfEntityCollectionElmahUser> Upsert(Elmah.DataSourceEntities.ElmahUser input)
        {
            //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            var _retval = new Elmah.DataSourceEntities.DataAccessLayerMessageOfEntityCollectionElmahUser();

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

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

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

                await this.LinqContext.SaveChangesAsync();

                Elmah.DataSourceEntities.ElmahUser _Result = new Elmah.DataSourceEntities.ElmahUser();
                _Result.CopyFrom <Elmah.EntityFrameworkContext.ElmahUser>(_LinqItem);
                _retval.Result = new List <Elmah.DataSourceEntities.ElmahUser>();
                _retval.Result.Add(_Result);
            }
            //log.Info(string.Format("{0}: Update", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));
            return(_retval);
        }
コード例 #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.DataAccessLayerMessageOfEntityCollectionElmahUser> DeleteByIdentifier(Elmah.DataSourceEntities.ElmahUserIdentifier id)
        {
            //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString()));

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

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

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

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

                    this.LinqContext.ElmahUser.Remove(_LinqItem);
                    await this.LinqContext.SaveChangesAsync();
                }
            }
            //log.Info(string.Format("{0}: DeleteByIdentifier", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString()));
            return(_retval);
        }
コード例 #3
0
        /// <summary>
        /// Insert/Update an entity of <see cref=" Elmah.DataSourceEntities.ElmahUser"/>.
        /// http://[host]/api/ElmahUserApi/UpsertEntity
        /// </summary>
        /// <param name="input">input entity</param>
        public async Task <Elmah.CommonBLLEntities.ElmahUserResponseMessageBuiltIn> UpsertEntityAsync(
            Elmah.DataSourceEntities.ElmahUser input)
        {
            const string ActionName_UpsertEntity = "UpsertEntity";
            string       url = GetHttpRequestUrl(ActionName_UpsertEntity);

            return(await Post <Elmah.DataSourceEntities.ElmahUser, Elmah.CommonBLLEntities.ElmahUserResponseMessageBuiltIn>(url, input));
        }
コード例 #4
0
        public async Task <Elmah.CommonBLLEntities.ElmahUserResponseMessageBuiltIn> UpsertEntity(
            [FromBody] Elmah.DataSourceEntities.ElmahUser input)
        {
            var request = new Elmah.CommonBLLEntities.ElmahUserRequestMessageBuiltIn();

            request.Criteria.Add(input);
            Elmah.CommonBLLEntities.ElmahUserResponseMessageBuiltIn responseMessage = await this.ThisService.UpsertEntity(request);

            return(responseMessage);;
        }
コード例 #5
0
        private Elmah.DataSourceEntities.ElmahUser CreateEmptyEntityOrGetFromTempData(string tempDataKey_ElmahUserController_Copy)
        {
            Elmah.DataSourceEntities.ElmahUser entity;
            if (TempData.ContainsKey(tempDataKey_ElmahUserController_Copy) && TempData[tempDataKey_ElmahUserController_Copy] != null)
            {
                try
                {
                    entity = (Elmah.DataSourceEntities.ElmahUser)TempData[tempDataKey_ElmahUserController_Copy];
                    TempData.Keep(tempDataKey_ElmahUserController_Copy);
                }
                catch
                {
                    entity = new Elmah.DataSourceEntities.ElmahUser();
                }
            }
            else
            {
                entity = new Elmah.DataSourceEntities.ElmahUser();
            }

            return(entity);
        }
コード例 #6
0
ファイル: ItemVM.cs プロジェクト: davidzhaoblog/Elmah
        public static async Task <T> CreateNewViewModel <T>(IServiceProvider serviceProvider, Elmah.DataSourceEntities.ElmahUser entity)
            where T : ItemVM, new()
        {
            var uiAction = Framework.ViewModels.UIAction.Create;
            T   vm       = new T();

            vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.AddNew, Elmah.Resx.UIStringResourcePerApp.ElmahUser);
            //TODO: create a new new entry in xxx.UIStringResourceExt.resx file if you need, and uncomment next line, reference resource key here, then add in .cshtml file.
            //vm.ContentData.Summary = string.Format("{0} {1}", Framework.Resx.UIStringResource.AddNew, Elmah.Resx.UIStringResourcePerApp.ElmahUser);
            vm.ServiceProvider = serviceProvider;
            await vm.LoadExtraData(uiAction);

            vm.Item = entity;
            vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Launch);

            return(vm);
        }
コード例 #7
0
ファイル: ItemVM.cs プロジェクト: davidzhaoblog/Elmah
 public static async Task <ItemVM> CreateNewViewModel(IServiceProvider serviceProvider, Elmah.DataSourceEntities.ElmahUser entity)
 {
     return(await CreateNewViewModel <ItemVM>(serviceProvider, entity));
 }