Esempio n. 1
0
        // GET: Admin/SubscrsWidget
        public ActionResult Index(Guid id)
        {
            SubscrViewModel model = new SubscrViewModel
            {
                Subscrs         = _cmsRepository.GetSubscrs(id),
                SelectedSubscrs = _cmsRepository.GetSelectedSubscrs(id)
            };

            return(View(model));
        }
Esempio n. 2
0
        public ActionResult Save(Guid id, SubscrViewModel backModel)
        {
            ErrorMessage message = new ErrorMessage
            {
                Title = "Информация"
            };

            if (ModelState.IsValid)
            {
                backModel.Item.Id = id;
                if (_cmsRepository.CheckSubscrExists(id))
                {
                    _cmsRepository.UpdateSubscr(backModel.Item);
                    message.Info = "Запись обновлена";
                }
                else
                {
                    _cmsRepository.InsertSubscr(backModel.Item);
                    message.Info = "Запись добавлена";
                }
                message.Buttons = new ErrorMessageBtnModel[]
                {
                    new ErrorMessageBtnModel {
                        Url = StartUrl + Request.Url.Query, Text = "вернуться в список"
                    },
                    new ErrorMessageBtnModel {
                        Url = $"{StartUrl}/item/{id}", Text = "ок", Action = "false"
                    }
                };
            }
            else
            {
                message.Info    = "Ошибка в заполнении формы. Поля в которых допушены ошибки - помечены цветом";
                message.Buttons = new ErrorMessageBtnModel[]
                {
                    new ErrorMessageBtnModel {
                        Url = $"{StartUrl}/item/{id}", Text = "ок", Action = "false"
                    }
                };
            }

            model.Item      = _cmsRepository.GetSubscr(id);
            model.ErrorInfo = message;
            return(View("Item", model));
        }
Esempio n. 3
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            //Есть ли у сайта доступ к модулю
            if (!_cmsRepository.ModuleAllowed(ControllerName))
            {
                Response.Redirect("/Admin/");
            }

            model = new SubscrViewModel()
            {
                SiteId         = SiteId,
                PageName       = PageName,
                Settings       = SettingsInfo,
                ControllerName = ControllerName,
                ActionName     = ActionName,
                Sites          = _cmsRepository.GetSites(),
                MenuCMS        = MenuCmsCore,
                MenuModules    = MenuModulCore,

                Departments = new SelectList(_cmsRepository.GetDepartments()
                                             .Select(s => new SelectListItem
                {
                    Text  = s.Title,
                    Value = s.Id.ToString()
                }).ToArray(), "Value", "Text"),

                Managers = new SelectList(_cmsRepository.GetManagers()
                                          .Select(s => new SelectListItem
                {
                    Text  = s.Title,
                    Value = s.Id.ToString()
                }).ToArray(), "Value", "Text")
            };
        }