public SaveMap BeforeSaveEntities(SaveMap saveMap) { if (_storeId == Guid.Empty) { throw new InvalidOperationException("Invalid save attempt"); } foreach (var key in saveMap.Keys) { if (typeof(ISaveable).IsAssignableFrom(key)) { continue; } //if (_saveableTypes.Contains(key)) continue; // if varied for some reason const string message = "not authorized to save a '{0}' type."; throw new SaveException(string.Format(message, key)); } var rulesEngine = ZzaRulesEngine.Instance; var dataProvider = _dataProviderFactory(); var context = new ZzaSaveContext(_storeId, dataProvider, saveMap); foreach (var entityInfo in saveMap.Values.SelectMany(x => x)) { context.EntityInfo = entityInfo; var results = rulesEngine.ExecuteSaveRules(entityInfo, context).ToList(); if (!results.Ok()) { throw new SaveException(results.Errors()); } } return(saveMap); }
public SaveMap BeforeSaveEntities(SaveMap saveMap) { if (_storeId == Guid.Empty) { throw new InvalidOperationException("Invalid save attempt"); } foreach (var key in saveMap.Keys) { if (typeof (ISaveable).IsAssignableFrom(key)) continue; //if (_saveableTypes.Contains(key)) continue; // if varied for some reason const string message = "not authorized to save a '{0}' type."; throw new SaveException(string.Format(message, key)); } var rulesEngine = ZzaRulesEngine.Instance; var dataProvider = _dataProviderFactory(); var context = new ZzaSaveContext(_storeId, dataProvider, saveMap); foreach (var entityInfo in saveMap.Values.SelectMany(x => x)) { context.EntityInfo = entityInfo; var results = rulesEngine.ExecuteSaveRules(entityInfo, context).ToList(); if (!results.Ok()) { throw new SaveException(results.Errors()); } } return saveMap; }