Beispiel #1
0
        public void ConvertToDatabaseObject(string companyId, Tagge.Common.Models.ProductVariantRequest request)
        {
            // Properties
            DV_CompanyId = companyId;
            //ParentId = productId;
            Sku          = request.Sku;
            DefaultPrice = request.DefaultPrice;
            MSRP         = request.MSRP;
            SalePrice    = request.SalePrice;
            Barcode      = request.Barcode;
            Width        = request.Width;
            Height       = request.Height;
            Depth        = request.Depth;
            Weight       = request.Weight;
            Status       = request.Status;

            // Kit
            if (request.Kit != null)
            {
                Kit.ConvertToDatabaseObject(request.Kit);
            }

            // Inventory - Managed in PC_Inventory

            // Categories - Managed in PC_Category

            // Option Values
            if (request.Options != null)
            {
                foreach (var option in request.Options)
                {
                    var dbOptionValue = new PC_OptionValue();
                    dbOptionValue.ConvertToDatabaseObject(option);
                    Options.Add(dbOptionValue);
                }
            }

            // AlternateIds
            if (request.AlternateIds != null)
            {
                foreach (var alternateId in request.AlternateIds)
                {
                    var dbAlternateId = new PC_AlternateId();
                    dbAlternateId.ConvertToDatabaseObject(alternateId);
                    AlternateIds.Add(dbAlternateId);
                }
            }

            // Custom Fields - Managed in PC_CustomField

            // ExternalIds - Managed in PC_ExternalId
        }
        /// <summary>
        /// Converts the request to a database object
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="request"></param>
        public void ConvertToDatabaseObject(string companyId, Tagge.Common.Models.ProductRequest request)
        {
            // Properties
            DV_CompanyId     = companyId;
            Name             = request.Name;
            Sku              = request.Sku;
            Description      = request.Description;
            DefaultPrice     = request.DefaultPrice == null ? 0 : (decimal)request.DefaultPrice;
            MSRP             = request.MSRP;
            SalePrice        = request.SalePrice;
            TaxClass         = request.TaxClass;
            Barcode          = request.Barcode;
            Unit             = request.Unit;
            AllowDiscounts   = request.AllowDiscounts;
            AllowBackorders  = request.AllowBackorders;
            InStockThreshold = request.InStockThreshold;
            TrackingMethod   = request.TrackingMethod;
            Type             = request.Type;
            Status           = request.Status;
            Width            = request.Width;
            Height           = request.Height;
            Depth            = request.Depth;
            Weight           = request.Weight;
            IsActive         = true;

            // Kit
            if (request.Kit != null)
            {
                Kit.ConvertToDatabaseObject(request.Kit);
            }

            // Variants - Managed in PC_ProductVariant

            // Inventory - Managed in PC_Inventory

            // Categories - Managed in PC_Category

            // Options
            if (request.Options != null)
            {
                foreach (var option in request.Options)
                {
                    var dbOption = new PC_Option();
                    dbOption.ConvertToDatabaseObject(option);
                    Options.Add(dbOption);
                }
            }

            // Units
            if (request.Units != null)
            {
                foreach (var unit in request.Units)
                {
                    var dbUnit = new PC_ProductUnit();
                    dbUnit.ConvertToDatabaseObject(unit);
                    Units.Add(dbUnit);
                }
            }

            // AlternateIds
            if (request.AlternateIds != null)
            {
                foreach (var alternateId in request.AlternateIds)
                {
                    var dbAlternateId = new PC_AlternateId();
                    dbAlternateId.ConvertToDatabaseObject(alternateId);
                    AlternateIds.Add(dbAlternateId);
                }
            }

            // Custom Fields - Managed in PC_CustomField

            // ExternalIds - Managed in PC_ExternalId
        }