Ejemplo n.º 1
0
        public virtual ActionResult Details(int id)
        {
            var viewModel = new AdministratorViewModel <DetailsViewModel>();
            var response  = new SingleModelResponse <DetailsViewModel>
            {
                IsValid = true,
            };

            if (id == 0)
            {
                response = _helpService.SetNewView();

                viewModel.Data         = response.Model;
                viewModel.Descriptions = this.FillMultiLanguageBoxSimpleModel(
                    "description", response.Model.Descriptions);
                viewModel.Urls = this.FillMultiLanguageBoxSimpleModel(
                    "url", response.Model.Urls, new bool[] { true, false, false, false });

                viewModel.ButtonConfiguration = new ButtonControlViewModel
                {
                    ActionEdit = "edit",
                    ActionSave = "saveDetails",

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

                    NavigationCancel = Url.Action(
                        controllerName: "Help",
                        actionName: "Index"),
                    UrlSave = Url.Action(
                        controllerName: "Help",
                        actionName: "SaveViewHelpData")
                };

                return(View(viewModel));
            }

            response = _helpService.GetViewData(id);

            if (!response.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            viewModel.Data         = response.Model;
            viewModel.Descriptions = this.FillMultiLanguageBoxSimpleModel(
                "description", response.Model.Descriptions);
            viewModel.Urls = this.FillMultiLanguageBoxSimpleModel(
                "url", response.Model.Urls, new bool[] { true, false, false, false });

            viewModel.ButtonConfiguration = new ButtonControlViewModel
            {
                ActionCancel = "cancelDetails",
                ActionEdit   = "edit",
                ActionSave   = "saveDetails",

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

                UrlSave = Url.Action(
                    controllerName: "Help",
                    actionName: "SaveViewHelpData")
            };

            return(View(viewModel));
        }