Ejemplo n.º 1
0
        public (bool created, string errorMessage) Generate(int id)
        {
            var data = _dataGetter.GetData(id);

            (bool valid, string errorMessage)result = _dataValidator.ValidateData(data);

            if (!result.valid)
            {
                return(result);
            }

            ReportOutput reportOutput = _dataFormatter.FormatData(data);

            return(_reportDistributor.DistributeReport(reportOutput));
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ControllerBase controller = filterContext.Controller;
            IDataFormatter formatter  = controller.ViewData[DxaViewDataItems.DataFormatter] as IDataFormatter;

            // Once we got here, we expect the View Model to be enriched already, but in case of a Page Model,
            // the embedded Region/Entity Models won't be enriched yet.
            if (formatter != null && formatter.ProcessModel && controller is PageController)
            {
                PageModel pageModel = controller.ViewData.Model as PageModel;
                ((PageController)controller).EnrichEmbeddedModels(pageModel);
                ActionResult result = formatter.FormatData(filterContext, pageModel);
                if (result != null)
                {
                    filterContext.Result = result;
                }
            }
            base.OnActionExecuted(filterContext);
        }