public override void OnActionExecuting(HttpActionContext actionContext) { var model = (ContentItemSave)actionContext.ActionArguments["contentItem"]; var contentItemValidator = new ContentItemValidationHelper <IContent, ContentItemSave>(_logger, _umbracoContextAccessor); if (!ValidateAtLeastOneVariantIsBeingSaved(model, actionContext)) { return; } if (!contentItemValidator.ValidateExistingContent(model, actionContext)) { return; } if (!ValidateUserAccess(model, actionContext)) { return; } //validate for each variant that is being updated foreach (var variant in model.Variants.Where(x => x.Save)) { if (contentItemValidator.ValidateProperties(model, variant, actionContext)) { contentItemValidator.ValidatePropertyData(model, variant, variant.PropertyCollectionDto, actionContext.ModelState); } } }
public override void OnActionExecuting(HttpActionContext actionContext) { var model = (MediaItemSave)actionContext.ActionArguments["contentItem"]; var contentItemValidator = new ContentItemValidationHelper <IMedia, MediaItemSave>(_logger, _umbracoContextAccessor); if (ValidateUserAccess(model, actionContext)) { //now do each validation step if (contentItemValidator.ValidateExistingContent(model, actionContext)) { if (contentItemValidator.ValidateProperties(model, model, actionContext)) { contentItemValidator.ValidatePropertyData(model, model, model.PropertyCollectionDto, actionContext.ModelState); } } } }