/// <summary> /// Saves the catalog relation dto. /// </summary> /// <param name="dto">The dto.</param> public void SaveCatalogRelationDto(CatalogRelationDto dto) { CatalogRelationManager.SaveCatalogRelation(dto); }
/// <summary> /// Gets the catalog relation dto. /// </summary> /// <param name="catalogId">The catalog id.</param> /// <param name="catalogNodeId">The catalog node id.</param> /// <param name="catalogEntryId">The catalog entry id.</param> /// <param name="groupName">Name of the group.</param> /// <param name="responseGroup">The response group.</param> /// <returns></returns> public CatalogRelationDto GetCatalogRelationDto(int catalogId, int catalogNodeId, int catalogEntryId, string groupName, CatalogRelationResponseGroup responseGroup) { return(CatalogRelationManager.GetCatalogRelationDto(catalogId, catalogNodeId, catalogEntryId, groupName, responseGroup)); }
public CatalogRelationDto GetCatalogRelationDto(string assetKey) { return(CatalogRelationManager.GetCatalogRelationDto(assetKey)); }
protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item) { int i = 0; object objSysRowAction = Item[i++]; object objParentCode = Item[i++]; object objChildCode = Item[i++]; object objQuantity = Item[i++]; object objGroupName = Item[i++]; object objSortOrder = Item[i++]; CatalogRelationDto.CatalogEntryRelationRow catalogEntryRelationRow = null; CatalogRelationDto catalogRelationDto = new CatalogRelationDto(); try { RowAction sysRowAction = RowAction.Default; if (objSysRowAction != null) { sysRowAction = GetRowActionEnum((string)objSysRowAction); } string parentCode; if (!String.IsNullOrEmpty((string)objParentCode)) { parentCode = (string)objParentCode; } else { throw new AbsentValue("Parent Entry Code"); } string childCode; if (!String.IsNullOrEmpty((string)objChildCode)) { childCode = (string)objChildCode; } else { throw new AbsentValue("Child Entry Code"); } bool bIsNew = false; CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(parentCode, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo)); if (catalogEntryDto.CatalogEntry.Count > 0) { CatalogEntryDto.CatalogEntryRow entry = catalogEntryDto.CatalogEntry[0]; if (entry.ClassTypeId.Equals(EntryType.Product, StringComparison.OrdinalIgnoreCase) || entry.ClassTypeId.Equals(EntryType.Bundle, StringComparison.OrdinalIgnoreCase) || entry.ClassTypeId.Equals(EntryType.Package, StringComparison.OrdinalIgnoreCase) || entry.ClassTypeId.Equals(EntryType.DynamicPackage, StringComparison.OrdinalIgnoreCase)) { CatalogEntryDto childEntryDto = CatalogEntryManager.GetCatalogEntryDto(childCode, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo)); if (childEntryDto.CatalogEntry.Count > 0) { CatalogEntryDto.CatalogEntryRow childEntry = childEntryDto.CatalogEntry[0]; catalogRelationDto = CatalogRelationManager.GetCatalogRelationDto(this._CatalogId, 0, entry.CatalogEntryId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.CatalogEntry)); if (catalogRelationDto.CatalogEntryRelation.Count > 0) { DataRow[] drs = catalogRelationDto.CatalogEntryRelation.Select(String.Format("ParentEntryId = {0} AND ChildEntryId = {1}", entry.CatalogEntryId, childEntry.CatalogEntryId)); if (drs.Length > 0) { catalogEntryRelationRow = (CatalogRelationDto.CatalogEntryRelationRow)drs[0]; if (sysRowAction == RowAction.Insert) { throw new MDPImportException(String.Format("The Relation with Parent Entry code '{0}' and Child Entry code '{1}' already exists.", parentCode, childCode)); } if (sysRowAction == RowAction.Delete) { catalogEntryRelationRow.Delete(); CatalogRelationManager.SaveCatalogRelation(catalogRelationDto); return(0); } } } if (catalogEntryRelationRow == null) { if (sysRowAction == RowAction.Update) { throw new MDPImportException(String.Format("The Relation with Parent Entry code '{0}' and Child Entry code '{1}' does not exists.", parentCode, childCode)); } if (sysRowAction == RowAction.Delete) { throw new MDPImportException(String.Format("The Relation with Parent Entry code '{0}' and Child Entry code '{1}' does not exists.", parentCode, childCode)); } catalogEntryRelationRow = catalogRelationDto.CatalogEntryRelation.NewCatalogEntryRelationRow(); catalogEntryRelationRow.ParentEntryId = entry.CatalogEntryId; catalogEntryRelationRow.ChildEntryId = childEntry.CatalogEntryId; catalogEntryRelationRow.Quantity = 1; catalogEntryRelationRow.GroupName = String.Empty; catalogEntryRelationRow.SortOrder = 0; switch (entry.ClassTypeId) { case EntryType.Product: catalogEntryRelationRow.RelationTypeId = EntryRelationType.ProductVariation; break; case EntryType.Package: catalogEntryRelationRow.RelationTypeId = EntryRelationType.PackageEntry; break; case EntryType.Bundle: case EntryType.DynamicPackage: catalogEntryRelationRow.RelationTypeId = EntryRelationType.BundleEntry; break; } bIsNew = true; } } else { throw new MDPImportException(String.Format("The Child Entry with code '{0}' does not exists.", childCode)); } } else { throw new MDPImportException(String.Format("The Parent Entry with code '{0}' has wrong type ('{1}').", parentCode, entry.ClassTypeId)); } } else { throw new MDPImportException(String.Format("The Parent Entry with code '{0}' does not exists.", parentCode)); } //SalePrice if (objQuantity != null) { catalogEntryRelationRow.Quantity = (decimal)objQuantity; } if (objGroupName != null) { catalogEntryRelationRow.GroupName = (string)objGroupName; } if (objSortOrder != null) { catalogEntryRelationRow.SortOrder = (int)objSortOrder; } if (bIsNew) { catalogRelationDto.CatalogEntryRelation.AddCatalogEntryRelationRow(catalogEntryRelationRow); } using (TransactionScope tx = new TransactionScope()) { // Save modifications if (catalogRelationDto.HasChanges()) { CatalogContext.Current.SaveCatalogRelationDto(catalogRelationDto); } tx.Complete(); } } catch (Exception ex) { throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item); } return(catalogEntryRelationRow.ParentEntryId); }