/// <summary> /// Saves a collection of <see cref="IContentType"/> objects /// </summary> /// <param name="contentTypes">Collection of <see cref="IContentType"/> to save</param> /// <param name="userId">Optional id of the user saving the ContentType</param> public void Save(IEnumerable <IContentType> contentTypes, int userId = 0) { var asArray = contentTypes.ToArray(); if (SavingContentType.IsRaisedEventCancelled(new SaveEventArgs <IContentType>(asArray), this)) { return; } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateContentTypeRepository(uow)) { foreach (var contentType in asArray) { contentType.CreatorId = userId; repository.AddOrUpdate(contentType); } //save it all in one go uow.Commit(); } UpdateContentXmlStructure(asArray.Cast <IContentTypeBase>().ToArray()); } SavedContentType.RaiseEvent(new SaveEventArgs <IContentType>(asArray, false), this); Audit.Add(AuditTypes.Save, string.Format("Save ContentTypes performed by user"), userId, -1); }
/// <summary> /// Saves a collection of <see cref="IContentType"/> objects /// </summary> /// <param name="contentTypes">Collection of <see cref="IContentType"/> to save</param> /// <param name="userId">Optional id of the user saving the ContentType</param> public void Save(IEnumerable <IContentType> contentTypes, int userId = 0) { if (SavingContentType.IsRaisedEventCancelled(new SaveEventArgs <IContentType>(contentTypes), this)) { return; } var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateContentTypeRepository(uow)) { foreach (var contentType in contentTypes) { contentType.CreatorId = userId; repository.AddOrUpdate(contentType); } //save it all in one go uow.Commit(); SavedContentType.RaiseEvent(new SaveEventArgs <IContentType>(contentTypes, false), this); } Audit.Add(AuditTypes.Save, string.Format("Save ContentTypes performed by user"), userId, -1); }
/// <summary> /// Saves a single <see cref="IContentType"/> object /// </summary> /// <param name="contentType"><see cref="IContentType"/> to save</param> /// <param name="userId">Optional id of the user saving the ContentType</param> public void Save(IContentType contentType, int userId = 0) { if (SavingContentType.IsRaisedEventCancelled(new SaveEventArgs <IContentType>(contentType), this)) { return; } var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateContentTypeRepository(uow)) { contentType.CreatorId = userId; repository.AddOrUpdate(contentType); uow.Commit(); SavedContentType.RaiseEvent(new SaveEventArgs <IContentType>(contentType, false), this); } Audit.Add(AuditTypes.Save, string.Format("Save ContentType performed by user"), userId, contentType.Id); }
/// <summary> /// Saves a single <see cref="IContentType"/> object /// </summary> /// <param name="contentType"><see cref="IContentType"/> to save</param> /// <param name="userId">Optional id of the user saving the ContentType</param> public void Save(IContentType contentType, int userId = 0) { if (SavingContentType.IsRaisedEventCancelled(new SaveEventArgs <IContentType>(contentType), this)) { return; } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateContentTypeRepository(uow)) { ValidateLocked(contentType); // throws if invalid contentType.CreatorId = userId; repository.AddOrUpdate(contentType); uow.Commit(); } UpdateContentXmlStructure(contentType); } SavedContentType.RaiseEvent(new SaveEventArgs <IContentType>(contentType, false), this); Audit(AuditType.Save, string.Format("Save ContentType performed by user"), userId, contentType.Id); }