Example #1
0
        /// <summary>
        /// Not Currently Used
        /// </summary>
        /// <returns></returns>
        public Tagge.Common.Models.OptionValueResponse ConvertToOptionValueResponse()
        {
            var response = new Tagge.Common.Models.OptionValueResponse();

            // Properties
            response.Id         = PC_OptionValue_Id;
            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 - Managed in PC_ExternalId

            return(response);
        }
Example #2
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);
        }