Ejemplo n.º 1
0
        public async Task <ActionResult> Edit(Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM vm)
        {
            try
            {
                //log.Info(string.Format("{0}: Edit", Framework.Models.LoggingOptions.UI_Process_Started.ToString()));
                var entity = new Elmah.DataSourceEntities.ELMAH_Error();
                entity.CopyFrom <Elmah.EntityContracts.IELMAH_Error>(vm.Item);

                using (var scope = _serviceProvider.CreateScope())
                {
                    var serviceInstance = (Elmah.WcfContracts.IELMAH_ErrorService)scope.ServiceProvider.GetRequiredService(typeof(Elmah.WcfContracts.IELMAH_ErrorService));

                    var request1 = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageUserDefinedOfIdentifier();
                    request1.Criteria = new Elmah.CommonBLLEntities.ELMAH_ErrorChainedQueryCriteriaIdentifier();
                    request1.Criteria.Identifier.ErrorId.NullableValueToCompare = vm.Item.ErrorId;

                    var originalItem = await serviceInstance.GetCollectionOfEntityByIdentifier(request1);

                    entity.CopyFrom <Elmah.DataSourceEntities.ELMAH_Error>(originalItem.Message[0]);
                    // TODO: Some of the FKs not in view/.cshtml, must assigned here,
                    //entity.ParentBusinessEntityID = originalItem.Message[0].ParentBusinessEntityID;

                    var request = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageBuiltIn();

                    request.Criteria.Add(entity);
                    var _Response = await serviceInstance.UpsertEntity(request);

                    if (_Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK)
                    {
                        //log.Info(string.Format("{0}: Edit", Framework.Models.LoggingOptions.UI_Process_Ended.ToString()));
                        return(Redirect(Request.Headers["Referer"].ToString()));
                    }
                    else
                    {
                        vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                        //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.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                        vm.StatusOfResult        = _Response.BusinessLogicLayerResponseStatus;
                        vm.StatusMessageOfResult = _Response.ServerErrorMessage;
                        //log.Error(string.Format("{0}: Edit: {1}", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Failed.ToString(), _Response.ServerErrorMessage));
                        return(View(vm));
                    }
                }
            }
            catch (Exception ex)
            {
                Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Update;
                vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                //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.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                vm.StatusOfResult        = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
                vm.StatusMessageOfResult = ex.Message;
                vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Failed);
                //log.Error(string.Format("{0}: {1}, {2}, {3}", uiAction, Framework.Models.LoggingOptions.UI_Process_Failed.ToString(), vm.StatusOfResult, vm.StatusMessageOfResult));

                return(View(vm));
            }
        }
Ejemplo n.º 2
0
/*
 *      /// <summary>
 *      /// Inserts an entity of <see cref=" Elmah.DataSourceEntities.ELMAH_Error"/>.
 *      /// </summary>
 *      /// <param name="input">input entity</param>
 *      // [Authorize]
 *      [HttpPost, ActionName("InsertEntity")]
 *      public async Task<Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn.Default> InsertEntity(
 *          [FromBody] Elmah.DataSourceEntities.ELMAH_Error input)
 *      {
 *          var request = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageBuiltIn();
 *          request.Criteria.Add(input);
 *          Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn responseMessage = await this.ThisService.InsertEntity(request);
 *          return await LoadDefaultItem(responseMessage);;
 *      }
 *
 *      /// <summary>
 *      /// Updates an entity of <see cref=" Elmah.DataSourceEntities.ELMAH_Error"/>.
 *      /// </summary>
 *      /// <param name="input">input entity</param>
 *      // [Authorize]
 *      [HttpPut, ActionName("UpdateEntity")]
 *      public async Task<Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn.Default> UpdateEntity(
 *          [FromBody] Elmah.DataSourceEntities.ELMAH_Error input)
 *      {
 *          var request = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageBuiltIn();
 *          request.Criteria.Add(input);
 *          Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn responseMessage = await this.ThisService.UpdateEntity(request);
 *          return await LoadDefaultItem(responseMessage);;
 *      }
 */

        private async Task <Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn.Default> LoadDefaultItem(Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn responseMessage)
        {
            if (responseMessage.BusinessLogicLayerResponseStatus != Framework.Services.BusinessLogicLayerResponseStatus.MessageOK)
            {
                return new Elmah.CommonBLLEntities.ELMAH_ErrorResponseMessageBuiltIn.Default {
                           BusinessLogicLayerResponseStatus = responseMessage.BusinessLogicLayerResponseStatus, ServerErrorMessage = responseMessage.ServerErrorMessage
                }
            }
            ;
            var request1 = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageUserDefinedOfIdentifier();

            request1.Criteria.Identifier.ErrorId.NullableValueToCompare = responseMessage.Message[0].ErrorId;
            return(await this.ThisService.GetCollectionOfDefaultByIdentifier(request1));
        }