/// <summary> /// Deletes a single instance of <see cref="IDetachedContentType"/>. /// </summary> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events. /// </param> public void Delete(IDetachedContentType detachedContentType, bool raiseEvents = true) { if (raiseEvents) { if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IDetachedContentType>(detachedContentType), this)) { ((DetachedContentType)detachedContentType).WasCancelled = true; return; } } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateDetachedContentTypeRepository(uow)) { repository.Delete(detachedContentType); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <IDetachedContentType>(detachedContentType), this); } }
/// <summary> /// Gets <see cref="IContentType"/> from <see cref="IDetachedContentType"/>. /// </summary> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <returns> /// The <see cref="IContentType"/>. /// </returns> internal IContentType GetContentTypeFromDetachedContentType(IDetachedContentType detachedContentType) { if (detachedContentType == null || detachedContentType.ContentTypeKey == null) { return(null); } return(GetContentTypeByKey(detachedContentType.ContentTypeKey.Value)); }
/// <summary> /// Initializes a new instance of the <see cref="ProductVariantDetachedContent"/> class. /// </summary> /// <param name="productVariantKey"> /// The product variant key. /// </param> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <param name="cultureName"> /// The culture name. /// </param> /// <param name="detachedDataValuesCollection"> /// The detached data values collection. /// </param> public ProductVariantDetachedContent( Guid productVariantKey, IDetachedContentType detachedContentType, string cultureName, DetachedDataValuesCollection detachedDataValuesCollection) { Ensure.ParameterCondition(!Guid.Empty.Equals(productVariantKey), "productVariantKey"); Ensure.ParameterNotNull(detachedContentType, "detachedContentType"); Ensure.ParameterNotNullOrEmpty(cultureName, "cultureName"); this.ProductVariantKey = productVariantKey; this.DetachedContentType = detachedContentType; this.CultureName = cultureName; this.DetachedDataValues = detachedDataValuesCollection; }
/// <summary> /// Initializes a new instance of the <see cref="ProductVariantDetachedContent"/> class. /// </summary> /// <param name="productVariantKey"> /// The product variant key. /// </param> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <param name="cultureName"> /// The culture name. /// </param> /// <param name="detachedDataValuesCollection"> /// The detached data values collection. /// </param> public ProductVariantDetachedContent( Guid productVariantKey, IDetachedContentType detachedContentType, string cultureName, DetachedDataValuesCollection detachedDataValuesCollection) { Mandate.ParameterCondition(!Guid.Empty.Equals(productVariantKey), "productVariantKey"); Mandate.ParameterNotNull(detachedContentType, "detachedContentType"); Mandate.ParameterNotNullOrEmpty(cultureName, "cultureName"); this.ProductVariantKey = productVariantKey; this.DetachedContentType = detachedContentType; this.CultureName = cultureName; this.DetachedDataValues = detachedDataValuesCollection; }
/// <summary> /// Maps a <see cref="UmbContentTypeDisplay"/> to <see cref="IDetachedContentType"/>. /// </summary> /// <param name="umbContentType"> /// The Umbraco content type. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <returns> /// The <see cref="IDetachedContentType"/>. /// </returns> public static IDetachedContentType ToDetachedContentType(this UmbContentTypeDisplay umbContentType, IDetachedContentType destination) { destination.Name = umbContentType.Name; destination.ContentTypeKey = umbContentType.Key; return(destination); }
/// <summary> /// Initializes a new instance of the <see cref="ProductVariantDetachedContent"/> class. /// </summary> /// <param name="productVariantKey"> /// The product variant key. /// </param> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <param name="cultureName"> /// The culture name. /// </param> public ProductVariantDetachedContent(Guid productVariantKey, IDetachedContentType detachedContentType, string cultureName) : this(productVariantKey, detachedContentType, cultureName, new DetachedDataValuesCollection()) { }
/// <summary> /// Saves a single instance of <see cref="IDetachedContentType"/>. /// </summary> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events. /// </param> public void Save(IDetachedContentType detachedContentType, bool raiseEvents = true) { if (raiseEvents) if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IDetachedContentType>(detachedContentType), this)) { ((DetachedContentType)detachedContentType).WasCancelled = true; return; } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateDetachedContentTypeRepository(uow)) { repository.AddOrUpdate(detachedContentType); uow.Commit(); } } if (raiseEvents) Saved.RaiseEvent(new SaveEventArgs<IDetachedContentType>(detachedContentType), this); }
/// <summary> /// Maps <see cref="DetachedContentTypeDisplay"/> to <see cref="IDetachedContentType"/>. /// </summary> /// <param name="contentType"> /// The content type. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <returns> /// The <see cref="IDetachedContentType"/>. /// </returns> public static IDetachedContentType ToDetachedContentType(this DetachedContentTypeDisplay contentType, IDetachedContentType destination) { destination.Name = contentType.Name; destination.Description = contentType.Description; return destination; }
/// <summary> /// Maps a <see cref="UmbContentTypeDisplay"/> to <see cref="IDetachedContentType"/>. /// </summary> /// <param name="umbContentType"> /// The Umbraco content type. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <returns> /// The <see cref="IDetachedContentType"/>. /// </returns> public static IDetachedContentType ToDetachedContentType(this UmbContentTypeDisplay umbContentType, IDetachedContentType destination) { destination.Name = umbContentType.Name; destination.ContentTypeKey = umbContentType.Key; return destination; }
/// <summary> /// Maps <see cref="DetachedContentTypeDisplay"/> to <see cref="IDetachedContentType"/>. /// </summary> /// <param name="contentType"> /// The content type. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <returns> /// The <see cref="IDetachedContentType"/>. /// </returns> public static IDetachedContentType ToDetachedContentType(this DetachedContentTypeDisplay contentType, IDetachedContentType destination) { destination.Name = contentType.Name; destination.Description = contentType.Description; return(destination); }
/// <summary> /// Maps <see cref="IDetachedContentType"/> to <see cref="DetachedContentTypeDisplay"/>. /// </summary> /// <param name="dtc"> /// The <see cref="IDetachedContentType"/>. /// </param> /// <returns> /// The <see cref="DetachedContentTypeDisplay"/>. /// </returns> public static DetachedContentTypeDisplay ToDetachedContentTypeDisplay(this IDetachedContentType dtc) { return(AutoMapper.Mapper.Map <DetachedContentTypeDisplay>(dtc)); }
/// <summary> /// Gets <see cref="IContentType"/> from <see cref="IDetachedContentType"/>. /// </summary> /// <param name="detachedContentType"> /// The detached content type. /// </param> /// <returns> /// The <see cref="IContentType"/>. /// </returns> internal IContentType GetContentTypeFromDetachedContentType(IDetachedContentType detachedContentType) { if (detachedContentType == null || detachedContentType.ContentTypeKey == null) return null; return GetContentTypeByKey(detachedContentType.ContentTypeKey.Value); }