예제 #1
0
        public async Task <ActionResult> Edit(Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM vm)
        {
            try
            {
                //log.Info(string.Format("{0}: Edit", Framework.Models.LoggingOptions.UI_Process_Started.ToString()));
                var entity = vm.Item;

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

                    var request1 = new Elmah.CommonBLLEntities.ElmahApplicationRequestMessageUserDefinedOfIdentifier();
                    request1.Criteria = new Elmah.CommonBLLEntities.ElmahApplicationChainedQueryCriteriaIdentifier();
                    request1.Criteria.Identifier.Application.NullableValueToCompare = vm.Item.Application;

                    var originalItem = await serviceInstance.GetCollectionOfEntityByIdentifier(request1);

                    entity.CopyFrom <Elmah.DataSourceEntities.ElmahApplication>(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.ElmahApplicationRequestMessageBuiltIn();

                    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.ElmahApplication);
                        //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.ElmahApplication);
                        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.ElmahApplication);
                //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.ElmahApplication);
                vm.StatusOfResult        = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
                vm.StatusMessageOfResult = ex.Message;
                vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(Elmah.AspNetMvcCoreViewModel.ElmahApplication.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));
            }
        }
        public async Task <Elmah.ViewModelData.ElmahApplication.ItemVM> GetItemVM(
            string application = default(string))
        {
            Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM retval = new Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM();
            retval.SetServiceProvider(this._serviceProvider);
            await retval.Load(!string.IsNullOrEmpty(application), application, Framework.ViewModels.UIAction.ViewDetails);

            return(retval);
        }
예제 #3
0
        /// <summary>
        /// GET method of Adds the new <see cref="ElmahModel.ElmahApplication"/>.
        /// GET: /ElmahApplication/AddNew
        /// </summary>
        /// <returns></returns>
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> AddNew()
        {
            var entity = CreateEmptyEntityOrGetFromTempData(TempDataKey_ElmahApplicationController_Copy);

            Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Create;
            Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM vm = await Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM.CreateNewViewModel(this._serviceProvider, entity);

            await vm.LoadExtraData(uiAction);

            return(View(vm));
        }
예제 #4
0
        /// <summary>
        /// GET method of details page, based on identifier or unique constraint, this entity only, no related entities.
        /// GET: /ElmahApplication/Details/5
        /// </summary>
        /// <returns></returns>
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> Details(string application = default(string))
        {
            Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.ViewDetails;
            var vm = new Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM();

            vm.SetServiceProvider(this._serviceProvider);
            await vm.Load(!string.IsNullOrEmpty(application), application, uiAction);

            vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Details, Elmah.Resx.UIStringResourcePerApp.ElmahApplication);
            //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.Details, Elmah.Resx.UIStringResourcePerApp.ElmahApplication);

            return(View(vm));
        }
예제 #5
0
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> AddNew(Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM vm)
        {
            try
            {
                //log.Info(string.Format("{0}: AddNew", Framework.Models.LoggingOptions.UI_Process_Started.ToString()));
                var entity = vm.Item;

                using (var scope = _serviceProvider.CreateScope())
                {
                    var serviceInstance = (Elmah.WcfContracts.IElmahApplicationService)scope.ServiceProvider.GetRequiredService(typeof(Elmah.WcfContracts.IElmahApplicationService));
                    var request         = new Elmah.CommonBLLEntities.ElmahApplicationRequestMessageBuiltIn();

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

                    if (_Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK)
                    {
                        TempData[TempDataKey_ElmahApplicationController_Copy] = null;
                        TempData.Remove(TempDataKey_ElmahApplicationController_Copy);
                        //log.Info(string.Format("{0}: Insert", Framework.Models.LoggingOptions.UI_Process_Ended.ToString()));

                        return(Redirect(Request.Headers["Referer"].ToString()));
                    }
                    else
                    {
                        vm = await Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM.CreateNewViewModel(this._serviceProvider, vm.Item);

                        vm.StatusOfResult        = _Response.BusinessLogicLayerResponseStatus;
                        vm.StatusMessageOfResult = _Response.ServerErrorMessage;
                        //log.Error(string.Format("{0}: AddNew: {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.Create;
                var entity = CreateEmptyEntityOrGetFromTempData(TempDataKey_ElmahApplicationController_Copy);
                vm = await Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM.CreateNewViewModel(this._serviceProvider, entity);

                vm.StatusOfResult        = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
                vm.StatusMessageOfResult = ex.Message;
                vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Failed);
                //log.Error(string.Format("{0}: AddNew: {1}", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Failed.ToString(), ex.Message));
                return(View(vm));
            }
        }
예제 #6
0
        public async Task <ActionResult> Delete(string application = default(string), Elmah.AspNetMvcCoreViewModel.ElmahApplication.ItemVM vm = null)
        {
            // The Delete is commented out.
            // remove [System.Diagnostics.CodeAnalysis.SuppressMessage("Await.Warning", "CS1998:Await.Warning")]
            // if you make it working
            // or remove async to make this method sync method

            return(Ok());

/*
 *          try
 *          {
 *              //log.Info(string.Format("{0}: Delete", Framework.Models.LoggingOptions.UI_Process_Started.ToString()));
 *              using (var scope = _serviceProvider.CreateScope())
 *              {
 *                  var serviceInstance = (Elmah.WcfContracts.IElmahApplicationService)scope.ServiceProvider.GetRequiredService(typeof(Elmah.WcfContracts.IElmahApplicationService));
 *                  var _Response1 = await serviceInstance.ExistsOfEntityByIdentifier(!string.IsNullOrEmpty(application), application, -1, -1, null);
 *                  if (_Response1.Message)
 *                  {
 *                      var entity = vm.Item;
 *
 *                      var _Response = await serviceInstance.DeleteEntity(entity);
 *                      if (_Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK)
 *                      {
 *                          //log.Info(string.Format("{0}: Delete", Framework.Models.LoggingOptions.UI_Process_Ended.ToString()));
 *                      }
 *                      else
 *                      {
 *                          vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Delete, Elmah.Resx.UIStringResourcePerApp.ElmahApplication);
 *                          //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.Delete, Elmah.Resx.UIStringResourcePerApp.ElmahApplication);
 *                          vm.StatusOfResult = _Response.BusinessLogicLayerResponseStatus;
 *                          vm.StatusMessageOfResult = _Response.ServerErrorMessage;
 *                          //log.Error(string.Format("{0}: Delete: {1}", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Failed.ToString(), _Response.ServerErrorMessage));
 *                          return View(vm);
 *                      }
 *                  }
 *                  else
 *                  {
 *                      //log.Warn(string.Format("{0}: Delete, Entity not exists",  Framework.Models.LoggingOptions.UI_Process_Ended.ToString()));
 *                  }
 *
 *                  return Redirect(Request.Headers["Referer"].ToString());
 *              }
 *          }
 *          catch (Exception ex)
 *          {
 *              Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Delete;
 *              vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Delete, Elmah.Resx.UIStringResourcePerApp.ElmahApplication);
 *              //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.Delete, Elmah.Resx.UIStringResourcePerApp.ElmahApplication);
 *              vm.StatusOfResult = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
 *              vm.StatusMessageOfResult = ex.Message;
 *              vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(Elmah.AspNetMvcCoreViewModel.ElmahApplication.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);
 *          }
 */
        }