Exemplo n.º 1
0
        /// <summary>
        /// Finds the items dto.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="options">The options.</param>
        /// <param name="recordsCount">The records count.</param>
        /// <returns></returns>
        public CatalogEntryDto FindItemsDto(CatalogSearchParameters parameters, CatalogSearchOptions options, ref int recordsCount)
        {
            CatalogSearch search = new CatalogSearch();

            search.SearchOptions    = options;
            search.SearchParameters = parameters;
            return(CatalogEntryManager.FindItemsDto(search, ref recordsCount, new CatalogEntryResponseGroup()));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds the items.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public Entries FindItems(CatalogSearchParameters parameters, CatalogSearchOptions options)
        {
            CatalogSearch search = new CatalogSearch();

            search.SearchOptions    = options;
            search.SearchParameters = parameters;
            return(CatalogEntryManager.FindItems(search, new CatalogEntryResponseGroup()));
        }
Exemplo n.º 3
0
        protected override int CreateSystemRow(FillDataMode mode, int RowIndex, params object[] item)
        {
            int    i = 0;
            object objSysRowAction = item[i++];
            //Entry
            object objCode          = item[i++];
            object objName          = item[i++];
            object objClassTypeId   = item[i++];
            object objStartDate     = item[i++];
            object objEndDate       = item[i++];
            object objTemplateName  = item[i++];
            object objIsActive      = item[i++];
            object objCategoryCodes = item[i++];
            object objSortOrder     = item[i++];
            //SEO
            object objSeoTitle       = item[i++];
            object objSeoUrl         = item[i++];
            object objSeoDescription = item[i++];
            object objSeoKeywords    = item[i++];

            CatalogEntryDto.CatalogEntryRow entryRow = null;

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string code;
                if (objCode != null)
                {
                    code = (string)objCode;
                }
                else
                {
                    throw new AbsentValue("Code");
                }

                bool            bIsNew          = false;
                CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                if (catalogEntryDto.CatalogEntry.Count > 0)
                {
                    if (sysRowAction == RowAction.Insert)
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' already exists.", code));
                    }

                    entryRow = catalogEntryDto.CatalogEntry[0];

                    if (sysRowAction == RowAction.Delete)
                    {
                        CatalogContext.Current.DeleteCatalogEntry(entryRow.CatalogEntryId, true);
                        return(0);
                    }
                }
                else
                {
                    if (sysRowAction == RowAction.Update)
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", code));
                    }

                    if (sysRowAction == RowAction.Delete)
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", code));
                    }

                    entryRow = catalogEntryDto.CatalogEntry.NewCatalogEntryRow();
                    entryRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId;
                    entryRow.CatalogId     = _CatalogId;
                    entryRow.Code          = code;
                    bIsNew = true;
                }

                //Entry
                if (objName != null)
                {
                    string Name = (string)objName;
                    entryRow.Name = Name;
                }
                else if (bIsNew)
                {
                    throw new AbsentValue("Name");
                }

                if (objClassTypeId != null)
                {
                    string classTypeId = (string)objClassTypeId;
                    entryRow.ClassTypeId = classTypeId;
                }
                else if (bIsNew)
                {
                    entryRow.ClassTypeId = EntryType.Product;
                }

                if (objStartDate != null)
                {
                    DateTime startDate = (DateTime)objStartDate;
                    entryRow.StartDate = startDate.ToUniversalTime();
                }
                else if (bIsNew)
                {
                    entryRow.StartDate = DateTime.UtcNow;
                }

                if (objEndDate != null)
                {
                    DateTime endDate = (DateTime)objEndDate;
                    entryRow.EndDate = endDate.ToUniversalTime();
                }
                else if (bIsNew)
                {
                    entryRow.EndDate = DateTime.UtcNow.AddYears(1);
                }

                if (objTemplateName != null)
                {
                    string templateName = (string)objTemplateName;
                    entryRow.TemplateName = templateName;
                }
                else if (bIsNew)
                {
                    entryRow.TemplateName = String.Empty;
                }

                if (objIsActive != null)
                {
                    bool IsActive = (bool)objIsActive;
                    entryRow.IsActive = IsActive;
                }
                else if (bIsNew)
                {
                    entryRow.IsActive = false;
                }

                int oldMetaClassId = 0;
                if (!_isSystemClass && _metaClassId > 0)
                {
                    if (!bIsNew)
                    {
                        oldMetaClassId = entryRow.MetaClassId;
                    }

                    entryRow.MetaClassId = _metaClassId;
                }
                else if (bIsNew)
                {
                    throw new MDPImportException("The new entry cannot be created without metaclass definition.");
                }

                if (bIsNew)
                {
                    catalogEntryDto.CatalogEntry.AddCatalogEntryRow(entryRow);
                }
                else
                {
                    entryRow.SerializedData = null;
                }

                //SEO
                CatalogEntryDto.CatalogItemSeoRow catalogItemSeoRow = null;
                bool bSeoIsNew = false;
                if (!String.IsNullOrEmpty(this.Context.Language))
                {
                    if (catalogEntryDto.CatalogItemSeo.Count > 0)
                    {
                        DataRow[] drs = catalogEntryDto.CatalogItemSeo.Select(String.Format("LanguageCode LIKE '{0}' AND CatalogEntryId = {1}", this.Context.Language, entryRow.CatalogEntryId));
                        if (drs.Length > 0)
                        {
                            catalogItemSeoRow = (CatalogEntryDto.CatalogItemSeoRow)drs[0];
                        }
                    }

                    if (catalogItemSeoRow == null)
                    {
                        catalogItemSeoRow = catalogEntryDto.CatalogItemSeo.NewCatalogItemSeoRow();
                        catalogItemSeoRow.ApplicationId  = CatalogConfiguration.Instance.ApplicationId;
                        catalogItemSeoRow.LanguageCode   = this.Context.Language.ToLower();
                        catalogItemSeoRow.CatalogEntryId = entryRow.CatalogEntryId;
                        bSeoIsNew = true;
                    }

                    if (objSeoTitle != null)
                    {
                        catalogItemSeoRow.Title = (string)objSeoTitle;
                    }

                    if (objSeoUrl != null)
                    {
                        catalogItemSeoRow.Uri = (string)objSeoUrl;
                    }
                    else if (bSeoIsNew)
                    {
                        // Auto generate the URL if empty
                        string name = catalogEntryDto.CatalogEntry.Count > 0 ? catalogEntryDto.CatalogEntry[0].Name : "";
                        string url  = String.Format("{0}.aspx", CommerceHelper.CleanUrlField(name));

                        int index = 1;
                        while (CatalogContext.Current.GetCatalogEntryByUriDto(url, this.Context.Language).CatalogEntry.Count != 0 || CatalogContext.Current.GetCatalogNodeDto(url, this.Context.Language).CatalogNode.Count != 0)
                        {
                            url = String.Format("{0}-{1}.aspx", CommerceHelper.CleanUrlField(name), index.ToString());
                            index++;
                        }

                        catalogItemSeoRow.Uri = url;
                    }

                    if (objSeoDescription != null)
                    {
                        catalogItemSeoRow.Description = (string)objSeoDescription;
                    }

                    if (objSeoKeywords != null)
                    {
                        catalogItemSeoRow.Keywords = (string)objSeoKeywords;
                    }

                    if (bSeoIsNew)
                    {
                        catalogEntryDto.CatalogItemSeo.AddCatalogItemSeoRow(catalogItemSeoRow);
                    }
                }

                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogEntryDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    }

                    int sortOrder = -1;
                    if (objSortOrder != null)
                    {
                        sortOrder = (int)objSortOrder;
                    }

                    if (objCategoryCodes != null)
                    {
                        //NodeEntryRelation

                        string[] categoryCodes = ((string)objCategoryCodes).Split(',');

                        Catalog.Dto.CatalogRelationDto catalogRelationDto = FrameworkContext.Current.CatalogSystem.GetCatalogRelationDto(this._CatalogId, 0, entryRow.CatalogEntryId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.NodeEntry));

                        Catalog.Dto.CatalogNodeDto catalogNodeDto = FrameworkContext.Current.CatalogSystem.GetCatalogNodesDto(this._CatalogId);
                        if (catalogNodeDto.CatalogNode.Count > 0)
                        {
                            //remove product from category
                            if (catalogRelationDto.NodeEntryRelation.Count > 0)
                            {
                                foreach (CatalogRelationDto.NodeEntryRelationRow nodeEntryRelationRow in catalogRelationDto.NodeEntryRelation)
                                {
                                    DataRow[] catalogNodeDataRows = catalogNodeDto.CatalogNode.Select(String.Format("CatalogNodeId = {0}", nodeEntryRelationRow.CatalogNodeId));
                                    if (catalogNodeDataRows.Length > 0)
                                    {
                                        Catalog.Dto.CatalogNodeDto.CatalogNodeRow catalogNode = (Catalog.Dto.CatalogNodeDto.CatalogNodeRow)catalogNodeDataRows[0];

                                        bool bExist = false;
                                        foreach (string categoryCode in categoryCodes)
                                        {
                                            if (catalogNode.Code.Equals(categoryCode))
                                            {
                                                if (sortOrder >= 0)
                                                {
                                                    nodeEntryRelationRow.SortOrder = sortOrder;
                                                }

                                                bExist = true;
                                                break;
                                            }
                                        }
                                        if (!bExist)
                                        {
                                            nodeEntryRelationRow.Delete();
                                        }
                                    }
                                }
                            }

                            //add entry to category
                            foreach (string categoryCode in categoryCodes)
                            {
                                DataRow[] catalogNodeDataRows = catalogNodeDto.CatalogNode.Select(String.Format("Code = '{0}'", categoryCode.Replace("'", "''")));
                                if (catalogNodeDataRows.Length > 0)
                                {
                                    Catalog.Dto.CatalogNodeDto.CatalogNodeRow catalogNode = (Catalog.Dto.CatalogNodeDto.CatalogNodeRow)catalogNodeDataRows[0];

                                    DataRow[] nodeEntryRelationDataRows = catalogRelationDto.NodeEntryRelation.Select(String.Format("CatalogNodeId = {0}", catalogNode.CatalogNodeId));
                                    if (nodeEntryRelationDataRows.Length == 0)
                                    {
                                        Catalog.Dto.CatalogRelationDto.NodeEntryRelationRow row = catalogRelationDto.NodeEntryRelation.NewNodeEntryRelationRow();
                                        row.CatalogId      = this._CatalogId;
                                        row.CatalogEntryId = entryRow.CatalogEntryId;
                                        row.CatalogNodeId  = catalogNode.CatalogNodeId;

                                        if (sortOrder >= 0)
                                        {
                                            row.SortOrder = sortOrder;
                                        }
                                        else
                                        {
                                            row.SortOrder = 0;
                                        }

                                        catalogRelationDto.NodeEntryRelation.AddNodeEntryRelationRow(row);
                                    }
                                }
                            }
                        }

                        if (catalogRelationDto.HasChanges())
                        {
                            CatalogContext.Current.SaveCatalogRelationDto(catalogRelationDto);
                        }
                    }

                    if (!bIsNew && !_isSystemClass && oldMetaClassId != entryRow.MetaClassId)
                    {
                        MetaObject.Delete(this.Context, entryRow.CatalogEntryId, oldMetaClassId);
                        MetaObject obj = MetaObject.NewObject(this.Context, entryRow.CatalogEntryId, entryRow.MetaClassId);
                        obj.AcceptChanges(this.Context);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, item);
            }

            return(entryRow.CatalogEntryId);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="cacheResults">if set to <c>true</c> [cache results].</param>
 /// <param name="cacheTimeout">The cache timeout.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int[] catalogEntries, bool cacheResults, TimeSpan cacheTimeout, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogEntries, cacheResults, cacheTimeout, responseGroup));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the catalog entries.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="catalogCode">The catalog code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(string catalogName, string catalogCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntries(catalogName, catalogCode, responseGroup));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the catalog entry.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <returns></returns>
 public Entry GetCatalogEntry(string code)
 {
     return(CatalogEntryManager.GetCatalogEntry(code, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the catalog entry.
 /// </summary>
 /// <param name="catalogEntryId">The catalog entry id.</param>
 /// <returns></returns>
 public Entry GetCatalogEntry(int catalogEntryId)
 {
     return(CatalogEntryManager.GetCatalogEntry(catalogEntryId, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Deletes the entry.
 /// </summary>
 /// <param name="entryId">The entry id.</param>
 /// <param name="recursive">if set to <c>true</c> [recursive].</param>
 public void DeleteCatalogEntry(int entryId, bool recursive)
 {
     CatalogEntryManager.DeleteCatalogEntry(entryId, recursive);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Gets the catalog entry by URI dto.
 /// </summary>
 /// <param name="uri">The URI.</param>
 /// <param name="languageCode">The language code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntryByUriDto(string uri, string languageCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntryByUriDto(uri, languageCode, responseGroup));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="parentNodeId">The parent node id.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(string catalogName, int parentNodeId)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogName, parentNodeId, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gets merchants.
 /// </summary>
 /// <returns></returns>
 public CatalogEntryDto GetMerchantsDto()
 {
     return(CatalogEntryManager.GetMerchants());
 }
Exemplo n.º 12
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(int[] catalogEntries, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntries(catalogEntries, false, new TimeSpan(), responseGroup));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Gets the catalog entries.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="cacheResults">if set to <c>true</c> [cache results].</param>
 /// <param name="cacheTimeout">The cache timeout.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(int[] catalogEntries, bool cacheResults, TimeSpan cacheTimeout)
 {
     return(CatalogEntryManager.GetCatalogEntries(catalogEntries, cacheResults, cacheTimeout, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 14
0
        protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item)
        {
            int    i = 0;
            object objSysRowAction = Item[i++];
            object objCode         = Item[i++];
            //Variation
            object objListPrice      = Item[i++];
            object objTaxCategoryId  = Item[i++];
            object objTrackInventory = Item[i++];
            object objMerchantId     = Item[i++];
            object objWarehouseId    = Item[i++];
            object objWeight         = Item[i++];
            object objPackageId      = Item[i++];
            object objMinQuantity    = Item[i++];
            object objMaxQuantity    = Item[i++];
            //Inventory
            object objInStockQuantity           = Item[i++];
            object objReservedQuantity          = Item[i++];
            object objReorderMinQuantity        = Item[i++];
            object objPreorderQuantity          = Item[i++];
            object objBackorderQuantity         = Item[i++];
            object objAllowBackorder            = Item[i++];
            object objAllowPreorder             = Item[i++];
            object objInventoryStatus           = Item[i++];
            object objPreorderAvailabilityDate  = Item[i++];
            object objBackorderAvailabilityDate = Item[i++];

            CatalogEntryDto.VariationRow variationRow = null;
            CatalogEntryDto.InventoryRow inventoryRow = null;

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string Code;
                if (objCode != null)
                {
                    Code = (string)objCode;
                }
                else
                {
                    throw new AbsentValue("Code");
                }

                bool            bVariationIsNew = false;
                bool            bInventoryIsNew = false;
                CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(Code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                if (catalogEntryDto.CatalogEntry.Count > 0)
                {
                    CatalogEntryDto.CatalogEntryRow entry = catalogEntryDto.CatalogEntry[0];
                    if (entry.ClassTypeId.Equals(EntryType.Variation, StringComparison.OrdinalIgnoreCase) ||
                        entry.ClassTypeId.Equals(EntryType.Package, StringComparison.OrdinalIgnoreCase))
                    {
                        if (catalogEntryDto.Variation.Count > 0)
                        {
                            if (sysRowAction == RowAction.Insert)
                            {
                                throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' already exists.", Code));
                            }

                            variationRow = catalogEntryDto.Variation[0];

                            if (sysRowAction == RowAction.Delete)
                            {
                                variationRow.Delete();
                            }
                        }
                        else
                        {
                            if (sysRowAction == RowAction.Update)
                            {
                                throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' does not exists.", Code));
                            }

                            if (sysRowAction == RowAction.Delete)
                            {
                                throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' does not exists.", Code));
                            }

                            variationRow = catalogEntryDto.Variation.NewVariationRow();
                            variationRow.CatalogEntryId = entry.CatalogEntryId;
                            variationRow.ListPrice      = 0;
                            variationRow.TaxCategoryId  = 0;
                            variationRow.TrackInventory = false;
                            variationRow.WarehouseId    = 0;
                            variationRow.Weight         = 1;
                            variationRow.PackageId      = 0;
                            variationRow.MinQuantity    = 1;
                            variationRow.MaxQuantity    = 100;
                            bVariationIsNew             = true;
                        }

                        if (catalogEntryDto.Inventory.Count > 0)
                        {
                            if (sysRowAction == RowAction.Insert)
                            {
                                throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' already exists.", Code));
                            }

                            inventoryRow = catalogEntryDto.Inventory[0];

                            if (sysRowAction == RowAction.Delete)
                            {
                                inventoryRow.Delete();
                            }
                        }
                        else
                        {
                            if (sysRowAction == RowAction.Update)
                            {
                                throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' does not exists.", Code));
                            }

                            if (sysRowAction == RowAction.Delete)
                            {
                                throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' does not exists.", Code));
                            }

                            inventoryRow = catalogEntryDto.Inventory.NewInventoryRow();
                            inventoryRow.ApplicationId             = CatalogConfiguration.Instance.ApplicationId;
                            inventoryRow.SkuId                     = entry.Code;
                            inventoryRow.InStockQuantity           = 10;
                            inventoryRow.ReservedQuantity          = 2;
                            inventoryRow.ReorderMinQuantity        = 1;
                            inventoryRow.PreorderQuantity          = 10;
                            inventoryRow.BackorderQuantity         = 10;
                            inventoryRow.AllowBackorder            = false;
                            inventoryRow.AllowPreorder             = false;
                            inventoryRow.InventoryStatus           = 0;
                            inventoryRow.PreorderAvailabilityDate  = DateTime.UtcNow;
                            inventoryRow.BackorderAvailabilityDate = DateTime.UtcNow;
                            bInventoryIsNew = true;
                        }
                    }
                    else
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' has wrong type ('{1}') for Variation/Inventory import.", Code, entry.ClassTypeId));
                    }
                }
                else
                {
                    throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", Code));
                }

                if (sysRowAction == RowAction.Delete)
                {
                    CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    return(0);
                }

                //Variation
                if (objListPrice != null)
                {
                    decimal ListPrice = (decimal)objListPrice;
                    variationRow.ListPrice = ListPrice;
                }

                if (objTaxCategoryId != null)
                {
                    variationRow.TaxCategoryId = GetTaxCategoryId((string)objTaxCategoryId);
                }

                if (objTrackInventory != null)
                {
                    variationRow.TrackInventory = (bool)objTrackInventory;
                }

                if (objMerchantId != null)
                {
                    Guid merchantId = GetMerchantId((string)objMerchantId);
                    if (merchantId != Guid.Empty)
                    {
                        variationRow.MerchantId = merchantId;
                    }
                }

                if (objWarehouseId != null)
                {
                    variationRow.WarehouseId = GetWarehouseId((string)objWarehouseId);
                }

                if (objWeight != null)
                {
                    variationRow.Weight = (double)objWeight;
                }

                if (objPackageId != null)
                {
                    variationRow.PackageId = GetPackageId((string)objPackageId);
                }

                if (objMinQuantity != null)
                {
                    variationRow.MinQuantity = (decimal)objMinQuantity;
                }

                if (objMaxQuantity != null)
                {
                    variationRow.MaxQuantity = (decimal)objMaxQuantity;
                }

                if (bVariationIsNew)
                {
                    catalogEntryDto.Variation.AddVariationRow(variationRow);
                }

                //Inventory
                if (objInStockQuantity != null)
                {
                    inventoryRow.InStockQuantity = (decimal)objInStockQuantity;
                }

                if (objReservedQuantity != null)
                {
                    inventoryRow.ReservedQuantity = (decimal)objReservedQuantity;
                }

                if (objReorderMinQuantity != null)
                {
                    inventoryRow.ReorderMinQuantity = (decimal)objReorderMinQuantity;
                }

                if (objPreorderQuantity != null)
                {
                    inventoryRow.PreorderQuantity = (decimal)objPreorderQuantity;
                }

                if (objBackorderQuantity != null)
                {
                    inventoryRow.BackorderQuantity = (decimal)objBackorderQuantity;
                }

                if (objAllowBackorder != null)
                {
                    inventoryRow.AllowBackorder = (bool)objAllowBackorder;
                }

                if (objAllowPreorder != null)
                {
                    inventoryRow.AllowPreorder = (bool)objAllowPreorder;
                }

                if (objInventoryStatus != null)
                {
                    inventoryRow.InventoryStatus = (int)objInventoryStatus;
                }

                if (objPreorderAvailabilityDate != null)
                {
                    inventoryRow.PreorderAvailabilityDate = ((DateTime)objPreorderAvailabilityDate).ToUniversalTime();
                }

                if (objBackorderAvailabilityDate != null)
                {
                    inventoryRow.BackorderAvailabilityDate = ((DateTime)objBackorderAvailabilityDate).ToUniversalTime();
                }

                if (bInventoryIsNew)
                {
                    catalogEntryDto.Inventory.AddInventoryRow(inventoryRow);
                }



                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogEntryDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item);
            }

            return(variationRow.CatalogEntryId);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Gets the catalog entry dto.
 /// </summary>
 /// <param name="catalogEntryCode">The catalog entry code.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntryDto(string catalogEntryCode)
 {
     return(CatalogEntryManager.GetCatalogEntryDto(catalogEntryCode, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Gets the catalog entries by node dto.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="parentNodeCode">The parent node code.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesByNodeDto(string catalogName, string parentNodeCode)
 {
     return(CatalogEntryManager.GetCatalogEntriesByCatalogDto(catalogName, parentNodeCode, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Gets the catalog entry dto.
 /// </summary>
 /// <param name="catalogEntryCode">The catalog entry code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntryDto(string catalogEntryCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntryDto(catalogEntryCode, responseGroup));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogId">The catalog id.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int catalogId, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogId, responseGroup));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Saves the catalog entry.
 /// </summary>
 /// <param name="dto">The dto.</param>
 public void SaveCatalogEntry(CatalogEntryDto dto)
 {
     CatalogEntryManager.SaveCatalogEntry(dto);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogId">The catalog id.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int catalogId)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogId, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Gets the catalog entry.
 /// </summary>
 /// <param name="catalogEntryId">The catalog entry id.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entry GetCatalogEntry(int catalogEntryId, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntry(catalogEntryId, responseGroup));
 }
Exemplo n.º 22
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="parentEntryId">The parent entry id.</param>
 /// <param name="entryType">Type of the entry.</param>
 /// <param name="relationType">Type of the relation.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int parentEntryId, string entryType, string relationType)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(parentEntryId, entryType, relationType, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the catalog entry.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entry GetCatalogEntry(string code, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntry(code, responseGroup));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="entryType">Type of the entry.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(string name, string entryType, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(name, entryType, responseGroup));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Gets the catalog entry by URI.
 /// </summary>
 /// <param name="uri">The URI.</param>
 /// <param name="languageCode">The language code.</param>
 /// <returns></returns>
 public Entry GetCatalogEntryByUri(string uri, string languageCode)
 {
     return(CatalogEntryManager.GetCatalogEntryByUri(uri, languageCode, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Gets the associated catalog entries dto.
 /// </summary>
 /// <param name="parentEntryId">The parent entry id.</param>
 /// <param name="associationName">Name of the association.</param>
 /// <returns></returns>
 public CatalogEntryDto GetAssociatedCatalogEntriesDto(int parentEntryId, string associationName)
 {
     return(CatalogEntryManager.GetAssociatedCatalogEntriesDto(parentEntryId, associationName, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Gets the catalog entries.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="catalogCode">The catalog code.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(string catalogName, string catalogCode)
 {
     return(CatalogEntryManager.GetCatalogEntries(catalogName, catalogCode, new CatalogEntryResponseGroup()));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Gets the associated catalog entries dto.
 /// </summary>
 /// <param name="parentEntryCode">The parent entry code.</param>
 /// <param name="associationName">Name of the association.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetAssociatedCatalogEntriesDto(string parentEntryCode, string associationName, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetAssociatedCatalogEntriesDto(parentEntryCode, associationName, responseGroup));
 }
Exemplo n.º 29
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int[] catalogEntries)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogEntries, false, new TimeSpan(), new CatalogEntryResponseGroup()));
 }
Exemplo n.º 30
0
        /// <summary>
        /// Creates the system row.
        /// </summary>
        /// <param name="Mode">The mode.</param>
        /// <param name="RowIndex">Index of the row.</param>
        /// <param name="Item">The item.</param>
        /// <returns></returns>
        protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item)
        {
            int    i = 0;
            object objSysRowAction = Item[i++];
            object objCode         = Item[i++];
            //SaleType
            object objSaleType    = Item[i++];
            object objSaleCode    = Item[i++];
            object objUnitPrice   = Item[i++];
            object objCurrency    = Item[i++];
            object objMinQuantity = Item[i++];
            object objStartDate   = Item[i++];
            object objEndDate     = Item[i++];

            int salePriceId = 0;

            CatalogEntryDto.SalePriceRow newSalePriceRow = null;

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string Code;
                if (objCode != null)
                {
                    Code = (string)objCode;
                }
                else
                {
                    throw new AbsentValue("Code");
                }

                bool            bSalePriceIsNew = false;
                CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(Code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                if (catalogEntryDto.CatalogEntry.Count > 0)
                {
                    CatalogEntryDto.CatalogEntryRow entry = catalogEntryDto.CatalogEntry[0];
                    if (entry.ClassTypeId.Equals(EntryType.Variation, StringComparison.OrdinalIgnoreCase) ||
                        entry.ClassTypeId.Equals(EntryType.Package, StringComparison.OrdinalIgnoreCase))
                    {
                        if (catalogEntryDto.SalePrice.Count == 0)
                        {
                            if (sysRowAction == RowAction.Update)
                            {
                                throw new MDPImportException(String.Format("The Sales Price for Entry code '{0}' does not exists.", Code));
                            }

                            if (sysRowAction == RowAction.Delete)
                            {
                                throw new MDPImportException(String.Format("The Sales Price for Entry code '{0}' does not exists.", Code));
                            }

                            bSalePriceIsNew = true;
                        }

                        newSalePriceRow             = catalogEntryDto.SalePrice.NewSalePriceRow();
                        newSalePriceRow.ItemCode    = entry.Code;
                        newSalePriceRow.SaleType    = 0;
                        newSalePriceRow.SaleCode    = String.Empty;
                        newSalePriceRow.UnitPrice   = 0;
                        newSalePriceRow.Currency    = GetCatalogDefaultCurrency();
                        newSalePriceRow.MinQuantity = 0;
                        newSalePriceRow.StartDate   = DateTime.UtcNow;
                        newSalePriceRow.EndDate     = DateTime.UtcNow.AddMonths(1);
                    }
                    else
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' has wrong type ('{1}') for Variation/Inventory import.", Code, entry.ClassTypeId));
                    }
                }
                else
                {
                    throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", Code));
                }

                //SalePrice
                if (objSaleType != null)
                {
                    newSalePriceRow.SaleType = (int)GetSaleTypeId((string)objSaleType);
                }

                if (objSaleCode != null)
                {
                    newSalePriceRow.SaleCode = (string)objSaleCode;
                }

                if (objUnitPrice != null)
                {
                    newSalePriceRow.UnitPrice = (decimal)objUnitPrice;
                }

                if (objCurrency != null)
                {
                    newSalePriceRow.Currency = GetCurrencyCode((string)objCurrency);
                }

                if (objMinQuantity != null)
                {
                    newSalePriceRow.MinQuantity = (decimal)objMinQuantity;
                }

                if (objStartDate != null)
                {
                    newSalePriceRow.StartDate = ((DateTime)objStartDate).ToUniversalTime();
                }

                if (objEndDate != null)
                {
                    newSalePriceRow.EndDate = ((DateTime)objEndDate).ToUniversalTime();
                }

                if (bSalePriceIsNew)
                {
                    catalogEntryDto.SalePrice.AddSalePriceRow(newSalePriceRow);
                }
                else
                {
                    IEnumerable <int> result = from SalePriceTable in catalogEntryDto.SalePrice
                                               where SalePriceTable.SaleType == newSalePriceRow.SaleType &&
                                               SalePriceTable.SaleCode == newSalePriceRow.SaleCode &&
                                               SalePriceTable.Currency == newSalePriceRow.Currency &&
                                               SalePriceTable.StartDate == newSalePriceRow.StartDate &&
                                               SalePriceTable.EndDate == newSalePriceRow.EndDate
                                               select SalePriceTable.SalePriceId;

                    if (result.Count() == 0)
                    {
                        if (sysRowAction == RowAction.Update)
                        {
                            throw new MDPImportException(String.Format("The Sales Price for Entry code '{0}' does not exists.", Code));
                        }

                        if (sysRowAction == RowAction.Delete)
                        {
                            throw new MDPImportException(String.Format("The Sales Price for Entry code '{0}' does not exists.", Code));
                        }

                        catalogEntryDto.SalePrice.AddSalePriceRow(newSalePriceRow);
                    }
                    else
                    {
                        if (sysRowAction == RowAction.Insert)
                        {
                            throw new MDPImportException(String.Format("The Sales Price for Entry code '{0}' already exists.", Code));
                        }

                        CatalogEntryDto.SalePriceRow salePriceRow = catalogEntryDto.SalePrice.FindBySalePriceId(result.First());

                        if (sysRowAction == RowAction.Delete)
                        {
                            salePriceRow.Delete();
                        }

                        if (sysRowAction == RowAction.Update)
                        {
                            salePriceId              = salePriceRow.SalePriceId;
                            salePriceRow.UnitPrice   = newSalePriceRow.UnitPrice;
                            salePriceRow.MinQuantity = newSalePriceRow.MinQuantity;
                        }
                    }
                }

                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogEntryDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item);
            }

            return(salePriceId);
        }