using ElectroShop.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ElectroShop
{
    public static class Helper
    {
        public static string ParseParametersValuesOrNames(string cathegoryParameterName)
        {
            return cathegoryParameterName.Replace(";", "");
        }

        public static string ParseAllParameterValuesOrNames(List<ElectronicComponentCathegoryForComponentManagementModel> ParametersModels)
        {
            string parameterValuesParsed = "";
            int count = 0;
            foreach (var parameter in ParametersModels)
            {
                string cathegoryParameterValueParsed = Helper.ParseParametersValuesOrNames(parameter.ParameterValue);
                count++;
                if (count == ParametersModels.Count)
                {
                    parameterValuesParsed = parameterValuesParsed + cathegoryParameterValueParsed;
                }
                else
                {
                    parameterValuesParsed = parameterValuesParsed + cathegoryParameterValueParsed + ";";
                }
            }

            return parameterValuesParsed;
        }

    }
}
