protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

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

            model = new CartCategoryViewModel()
            {
                SiteId         = SiteId,
                PageName       = PageName,
                Settings       = SettingsInfo,
                ControllerName = ControllerName,
                ActionName     = ActionName,
                Sites          = _cmsRepository.GetSites(),
                MenuCMS        = MenuCmsCore,
                MenuModules    = MenuModulCore
            };
        }
        public ActionResult Save(Guid id, CartCategoryViewModel backModel, HttpPostedFileBase upload)
        {
            ErrorMessage message = new ErrorMessage
            {
                Title = "Информация"
            };

            if (ModelState.IsValid)
            {
                backModel.Item.Id = id;

                #region Сохранение изображения
                if (upload != null && upload.ContentLength > 0)
                {
                    string allowExt = Settings.PicTypes;
                    string fileExt  = upload.FileName.Substring(upload.FileName.LastIndexOf(".")).Replace(".", "").ToLower();

                    if (allowExt.ToLower().Contains(fileExt))
                    {
                        string savePath = Settings.UserFiles + SiteId + "/cart/";
                        backModel.Item.Icon = $"{savePath}{id}.{fileExt}";

                        if (!Directory.Exists(Server.MapPath(savePath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(savePath));
                        }

                        try
                        {
                            var filePath = Server.MapPath(backModel.Item.Icon);
                            if (System.IO.File.Exists(filePath))
                            {
                                System.IO.File.Delete(filePath);
                            }

                            upload.SaveAs(filePath);
                        }
#pragma warning disable CS0168 // The variable 'ex' is declared but never used
                        catch (Exception ex)
#pragma warning restore CS0168 // The variable 'ex' is declared but never used
                        {
                            //log
                        }
                    }
                }
                #endregion

                if (_cmsRepository.CheckCartCategoryExists(id))
                {
                    _cmsRepository.UpdateCartCategory(backModel.Item);
                    message.Info = "Запись обновлена";
                }
                else
                {
                    _cmsRepository.InsertCartCategory(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.PageName = "Категория товаров и услуг";
            model.Item     = _cmsRepository.GetCartCategory(id);
            if (model.Item != null)
            {
                filter = GetFilter();
                var cFilter = FilterModel.Extend <CartFilter>(filter);
                cFilter.CategoryId = id;

                model.ProductsList = _cmsRepository.GetProductsList(cFilter);
                ViewBag.Image      = model.Item.Icon;
            }

            model.ErrorInfo = message;
            return(View("Item", model));
        }