Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            CommonModels.MVCGetPartial thisModel = new CommonModels.MVCGetPartial
            {
                ViewName        = "_AntiForgery",
                _TempData       = null,
                _thisController = ControllerContext
            };

            var result = await mvcApplication.ReturnViewToStringAsync(thisModel);

            List <DynamicModels.RootReportFilter> getBaseAppfilters = new List <DynamicModels.RootReportFilter>();

            getBaseAppfilters.Add(new DynamicModels.RootReportFilter {
                FilterName = "ENABLED_", DBType = SqlDbType.VarChar, ParamValue = "Y"
            });

            DataTable getApps = await _DynamicOutputProcedures._DynoProcSearchAsync(_Connect, "Custom Query", "SP_S_VW__APPLICATIONS_SEARCH",
                                                                                    new DataTableDotNetModelMetaData { length = -1, order = "", start = 0, verify = "T" },
                                                                                    getBaseAppfilters);

            Revamp.IO.Tools.Box._WriteEventLog("Test", IO.Structs.Enums.EventLogType.success);

            return(View());
        }
Esempio n. 2
0
        public static string ReturnViewToString(CommonModels.MVCGetPartial thisModel)
        {
            //TODO: Review .Net Core Port COnversion

            /*thisModel._ViewData = thisModel._ViewData ?? null;
             *
             * thisModel._TempData = thisModel._TempData ?? null;
             *
             * thisModel._ViewData.Model = thisModel.model;
             *
             *
             *
             * using (var sw = new StringWriter())
             * {
             *  ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(thisModel._thisController, thisModel.ViewName);
             *
             *  ViewContext viewContext = new ViewContext(thisModel._thisController, viewResult.View, thisModel._ViewData, thisModel._TempData, sw);
             *
             *  viewResult.View.Render(viewContext, sw);
             *
             *  viewResult.ViewEngine.ReleaseView(thisModel._thisController, viewResult.View);
             *
             *  return sw.GetStringBuilder().ToString();
             * }*/
            return("Review this .Net Core Port");
        }
        public async Task <string> ReturnViewToStringAsync(CommonModels.MVCGetPartial thisModel)
        {
            var httpContext = new DefaultHttpContext {
                RequestServices = _serviceProvider
            };
            var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());

            using (var sw = new StringWriter())
            {
                var viewResult = _razorViewEngine.FindView(actionContext, thisModel.ViewName, false);

                if (viewResult.View == null)
                {
                    throw new ArgumentNullException($"{thisModel.ViewName} does not match any available view");
                }

                var viewDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary())
                {
                    Model = thisModel._TempData
                };

                var viewContext = new ViewContext(
                    actionContext,
                    viewResult.View,
                    viewDictionary,
                    new TempDataDictionary(actionContext.HttpContext, _tempDataProvider),
                    sw,
                    new HtmlHelperOptions()
                    );

                await viewResult.View.RenderAsync(viewContext);

                return(sw.ToString());
            }
        }
Esempio n. 4
0
        public async Task <string> ReturnViewToStringAsync(CommonModels.MVCGetPartial thisModel)
        {
            var result = await _viewRenderService.ReturnViewToStringAsync(thisModel);

            return(result);
        }