Ejemplo n.º 1
0
        public Tagge.Common.Models.ProductAlternateIdResponse ConvertToResponse(string companyId, string tableName, IMongoDatabase db)
        {
            var response = new Tagge.Common.Models.ProductAlternateIdResponse();

            // Properties
            response.Id   = PC_AlternateId_Id;
            response.Sku  = Sku;
            response.Unit = Unit;
            response.AlternateIdTypeId = PC_AlternateIdTypeId;
            response.AlternateId       = AlternateId;
            response.Description       = Description;

            // Custom Fields
            if (CustomFields != null)
            {
                response.CustomFields = new List <Tagge.Common.Models.GenericCustomFieldResponse>();
                foreach (var customField in CustomFields)
                {
                    response.CustomFields.Add(customField.ConvertToResponse());
                }
            }

            // ExternalIds
            response.ExternalIds = PC_ExternalId.ConvertToResponse(PC_AlternateId_Id, tableName, companyId, db);

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert To Response when part of a bigger item
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public Tagge.Common.Models.KitResponse ConvertToResponse(string companyId, string tableName, IMongoDatabase db)
        {
            var response = new Tagge.Common.Models.KitResponse();

            // Properties
            response.Id          = PC_Kit_Id;
            response.Sku         = Sku;
            response.Description = Description;
            response.Type        = Type;

            // Components
            if (Components != null)
            {
                response.Components = new List <Tagge.Common.Models.KitComponentResponse>();
                foreach (var component in Components)
                {
                    response.Components.Add(component.ConvertToResponse(companyId, tableName, db));
                }
            }

            // Custom Fields
            if (CustomFields != null)
            {
                response.CustomFields = new List <Tagge.Common.Models.GenericCustomFieldResponse>();
                foreach (var customField in CustomFields)
                {
                    response.CustomFields.Add(customField.ConvertToResponse());
                }
            }

            // ExternalIds
            response.ExternalIds = PC_ExternalId.ConvertToResponse(PC_Kit_Id, tableName, companyId, db);

            return(response);
        }
Ejemplo n.º 3
0
        public Tagge.Common.Models.OptionResponse ConvertToResponse(string companyId, string tableName, IMongoDatabase db)
        {
            var response = new Tagge.Common.Models.OptionResponse();

            // Properties
            response.Id         = PC_Option_Id;
            response.OptionName = Name;
            response.Type       = Type;
            response.Order      = Order;

            // Option Values
            if (Values != null)
            {
                response.Values = new List <Tagge.Common.Models.OptionValueResponse>();
                foreach (var value in Values)
                {
                    response.Values.Add(value.ConvertToResponse(companyId, "PC_ProductOptionValue", db));
                }
            }

            // Custom Fields
            if (CustomFields != null)
            {
                response.CustomFields = new List <Tagge.Common.Models.GenericCustomFieldResponse>();
                foreach (var customField in CustomFields)
                {
                    response.CustomFields.Add(customField.ConvertToResponse());
                }
            }

            // ExternalIds
            response.ExternalIds = PC_ExternalId.ConvertToResponse(PC_Option_Id, tableName, companyId, db);

            return(response);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts the database object to a response
        /// </summary>
        /// <returns></returns>
        public Tagge.Common.Models.ProductUnitResponse ConvertToResponse(string companyId, string tableName, IMongoDatabase db)
        {
            var response = new Tagge.Common.Models.ProductUnitResponse();

            // Properties
            response.Id           = PC_ProductUnit_Id;
            response.Name         = Name;
            response.Conversion   = Conversion;
            response.DefaultPrice = DefaultPrice;
            response.MSRP         = MSRP;
            response.SalePrice    = SalePrice;

            // Custom Fields
            if (CustomFields != null)
            {
                response.CustomFields = new List <Tagge.Common.Models.GenericCustomFieldResponse>();
                foreach (var customField in CustomFields)
                {
                    response.CustomFields.Add(customField.ConvertToResponse());
                }
            }

            // ExternalIds
            response.ExternalIds = PC_ExternalId.ConvertToResponse(PC_ProductUnit_Id, tableName, companyId, db);

            return(response);
        }
Ejemplo n.º 5
0
        public Tagge.Common.Models.KitComponentResponse ConvertToResponse(string companyId, string tableName, IMongoDatabase db)
        {
            var response = new Tagge.Common.Models.KitComponentResponse();

            // Properties
            response.Id       = PC_KitComponent_Id;
            response.Sku      = Sku;
            response.Quantity = Quantity;
            response.Unit     = Unit;
            response.Type     = Type;

            // Custom Fields
            if (CustomFields != null)
            {
                response.CustomFields = new List <Tagge.Common.Models.GenericCustomFieldResponse>();
                foreach (var customField in CustomFields)
                {
                    response.CustomFields.Add(customField.ConvertToResponse());
                }
            }

            // Modify the tablename slightly
            tableName = tableName + "Component";

            // ExternalIds
            response.ExternalIds = PC_ExternalId.ConvertToResponse(PC_KitComponent_Id, tableName, companyId, db);

            return(response);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Option Values on a Response
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="tableName"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public Tagge.Common.Models.OptionValueResponse ConvertToResponse(string companyId, string tableName, IMongoDatabase db)
        {
            var response = new Tagge.Common.Models.OptionValueResponse();

            // Set the basic id
            string optionId = PC_OptionValue_Id;

            // Get the option id
            if (tableName == "PC_ProductOptionValue")
            {
                string index        = $"|{Value}";
                int    indexOfSteam = optionId.IndexOf(index);
                if (indexOfSteam >= 0)
                {
                    optionId = optionId.Remove(indexOfSteam);
                }
            }
            else
            {
                string[] ids = optionId.Split('|');

                optionId = ids[0] + "|" + ids[2];
            }

            // Properties
            response.Id         = PC_OptionValue_Id;
            response.OptionId   = optionId;
            response.OptionName = OptionName;
            response.Value      = Value;
            response.Detail     = Detail;
            response.Order      = Order;

            // Custom Fields
            if (CustomFields != null)
            {
                response.CustomFields = new List <Tagge.Common.Models.GenericCustomFieldResponse>();
                foreach (var customField in CustomFields)
                {
                    response.CustomFields.Add(customField.ConvertToResponse());
                }
            }

            // ExternalIds
            response.ExternalIds = PC_ExternalId.ConvertToResponse(PC_OptionValue_Id, tableName, companyId, db);

            return(response);
        }