public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            var model = new GenericCatalogModel();

            //Get Templete List
            GetTemplateList();

            // Get BlockView List
            GetBlockViewList();

            //default values
            model.Published = true;
            model.ItemOnPage = _catalogSettings.DefaultGenericCatalogItemsOnPage;
            model.SizeOnMenu = _catalogSettings.DefaultSizeOnMenu;
            //model.TemplateModels = templateListModel;

            ViewData["autoUpload"] = _catalogSettings.AllowAutoUpload;
            ViewData["allowMultiFile"] = _catalogSettings.AllowUploadMultiFile;
            return View(model);
        }
        public ActionResult Create(GenericCatalogModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var genericCatalog = new GenericCatalog();

                genericCatalog.Icon = this.FileAfterUpload();
                genericCatalog.Name = model.Name.ToTitle(TitleStyle.FirstCaps);
                genericCatalog.SystemName = model.Name.ToSystemName();
                genericCatalog.ItemOnPage = model.ItemOnPage;
                genericCatalog.SizeOnMenu = model.SizeOnMenu;
                genericCatalog.Published = model.Published;
                genericCatalog.DisplayOrder = model.DisplayOrder;
                genericCatalog.BlockViewId = Convert.ToInt32(model.BlockViewId.GetEnumValue<BlockViewType>());
                genericCatalog.TemplateId = model.TemplateId;
                genericCatalog.SEOUrlName = model.Name.ToSEName();

                _genericCatalogService.InsertGenericCatalog(genericCatalog);

                return RedirectToAction("List");
            }

            // Get Template List
            GetTemplateList();

            // Get blockView List
            GetBlockViewList();

            return View(model);
        }
        public ActionResult Edit(GenericCatalogModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            var genericCatalog = _genericCatalogService.GetGenericCatalogById(model.Id);
            if (genericCatalog == null)
                //No poll found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                if (TempData["fileUploaded"] != null && model.OldFilePath != null && !string.Empty.Equals(model.OldFilePath))
                {
                    var oldIconPath = model.OldFilePath;
                    var dirOldIconPath = Server.MapPath(oldIconPath);
                    if (System.IO.File.Exists(dirOldIconPath) && oldIconPath != DefaultIconUrl)
                    {
                        System.IO.File.Delete(dirOldIconPath);
                    }
                }

                genericCatalog.Icon = this.FileAfterUpload(genericCatalog.Icon);
                genericCatalog.Name = model.Name.ToTitle(TitleStyle.FirstCaps);
                genericCatalog.SystemName = model.Name.ToSystemName();
                genericCatalog.ItemOnPage = model.ItemOnPage;
                genericCatalog.SizeOnMenu = model.SizeOnMenu;
                genericCatalog.Published = model.Published;
                genericCatalog.DisplayOrder = model.DisplayOrder;
                genericCatalog.BlockViewId = Convert.ToInt32(model.BlockViewId.GetEnumValue<BlockViewType>());
                genericCatalog.TemplateId = model.TemplateId;
                genericCatalog.SEOUrlName = model.Name.ToSEName();

                _genericCatalogService.UpdateGenericCatalog(genericCatalog);

                return RedirectToAction("List");
            }

            // Get Template List
            GetTemplateList();

            // Get blockView List
            GetBlockViewList();

            //Get Control Type List For Attribute
            GetControlTypeList();

            return View(model);
        }
        public ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            var genericCatalog = _genericCatalogService.GetGenericCatalogById(id);
            if (genericCatalog == null)
                //No poll found with the specified id
                return RedirectToAction("List");

            // Get Template List
            GetTemplateList();

            // Get blockView List
            GetBlockViewList();

            //Get Control Type List For Attribute
            GetControlTypeList();

            var model = new GenericCatalogModel();

            model.Id = genericCatalog.Id;
            model.Icon = genericCatalog.Icon;
            model.Name = genericCatalog.Name;
            model.ItemOnPage = genericCatalog.ItemOnPage;
            model.SizeOnMenu = genericCatalog.SizeOnMenu;
            model.BlockViewId = genericCatalog.BlockView.ToString();
            model.Published = genericCatalog.Published;
            model.DisplayOrder = genericCatalog.DisplayOrder;
            model.TemplateId = (genericCatalog.TemplateId.HasValue) ? genericCatalog.TemplateId.Value : 0;
            //model.TemplateModels = templateListModel;

            //this old way: use TempData["OldFilePath"]
            //TempData["OlfFilePath"] = genericCatalog.Icon;
            //this new way: use model prop named OldFilePath
            model.OldFilePath = genericCatalog.Icon;

            return View(model);
        }