Ejemplo n.º 1
0
        public virtual ActionResult Index()
        {
            var response = _helpService.GetViewsData();

            var viewModel = new AdministratorViewModel <IndexViewModel>
            {
                Data = response.Model,
                ButtonConfiguration = new ButtonControlViewModel
                {
                    ActionCancel = "cancelIndex",
                    ActionEdit   = "edit",
                    ActionSave   = "saveIndex",

                    HasEditButton = IDBContext.Current.HasPermission(
                        Permission.HELP_CONVERGENCE_WRITE),
                    HasNewButton = IDBContext.Current.HasPermission(
                        Permission.HELP_CONVERGENCE_WRITE),

                    NavigationNew = Url.Action(
                        controllerName: "Help",
                        actionName: "Details",
                        routeValues: new { id = 0 }),
                    UrlSave = Url.Action(
                        controllerName: "Help",
                        actionName: "DeleteViewsHelpData")
                }
            };

            if (!response.IsValid)
            {
                viewModel.ButtonConfiguration.HasEditButton = false;
                viewModel.ButtonConfiguration.HasNewButton  = false;
                ViewBag.ErrorMessage = response.ErrorMessage;

                return(View(viewModel));
            }

            if (!response.Model.HelpViews.HasAny())
            {
                viewModel.ButtonConfiguration.HasEditButton = false;
                ViewBag.ErrorMessage = response.ErrorMessage;

                return(View(viewModel));
            }

            return(View(viewModel));
        }