public ActionResult GenericCatalogAttributeUpdate(GenericCatalogAttributeModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            if (!ModelState.IsValid)
            {
                //display the first model error
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return Content(modelStateErrors.FirstOrDefault());
            }

            var genericCatalogAttribute = _genericCatalogService.GetGenericCatalogAttributeById(model.Id);
            if (genericCatalogAttribute == null)
                throw new ArgumentException("No Generic Catalog Attribute found with the specified id", "id");

            genericCatalogAttribute.Name = model.Name.ToTitle(TitleStyle.FirstCaps);
            genericCatalogAttribute.SystemName = model.Name.ToSystemName();
            genericCatalogAttribute.Published = model.Published;
            genericCatalogAttribute.DisplayOrder = (model.DisplayOrder < 0) ? 0 : model.DisplayOrder;
            genericCatalogAttribute.ControlTypeId = (int)model.ControlTypeId.GetEnumValue<AttributeControlType>();

            _genericCatalogService.UpdateGenericCatalog(genericCatalogAttribute.GenericCatalog);

            return GenericCatalogAttributes(genericCatalogAttribute.GenericCatalogId, command);
        }
        public ActionResult GenericCatalogAttributeAdd(int genericCatalogId, GenericCatalogAttributeModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGenericCatalogs))
                return AccessDeniedView();

            if (!ModelState.IsValid)
            {
                //display the first model error
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return Content(modelStateErrors.FirstOrDefault());
            }

            var genericCatalog = _genericCatalogService.GetGenericCatalogById(genericCatalogId);
            if (genericCatalog == null)
                throw new ArgumentException("No poll found with the specified id", "pollId");

            genericCatalog.Attributes.Add(new GenericCatalogAttribute
            {
                Name = model.Name.ToTitle(TitleStyle.FirstCaps),
                SystemName = model.Name.ToSystemName(),
                CreationDate = DateTime.Now,
                ModifiedDate = DateTime.Now,
                Published = model.Published,
                DisplayOrder = (model.DisplayOrder < 0) ? 0 : model.DisplayOrder,
                ControlTypeId = Convert.ToInt32(model.ControlTypeId.GetEnumValue<AttributeControlType>())

            });
            _genericCatalogService.UpdateGenericCatalog(genericCatalog);

            return GenericCatalogAttributes(genericCatalog.Id, command);
        }