private static void UpdateTestStep(QCTestCase test, ActivitiesGroup activitiesGroup, Activity identifiedActivity, ObservableList <ExternalItemFieldBase> designStepsFields, ObservableList <ExternalItemFieldBase> designStepsParamsFields)
        {
            QCTestCaseStepsColl testCaseDesignStep = QCRestAPIConnect.GetTestCasesSteps(new List <string> {
                test.Id
            });

            //delete the un-needed steps
            foreach (QCTestCaseStep step in testCaseDesignStep)
            {
                if (activitiesGroup.ActivitiesIdentifiers.Where(x => x.IdentifiedActivity.ExternalID == step.Id.ToString()).FirstOrDefault() == null)
                {
                    QCRestAPIConnect.DeleteEntity(ALM_Common.DataContracts.ResourceType.DESIGN_STEP, step.Id);
                }
            }

            //delete the existing parameters
            QCTestCaseParamsColl testCaseParams = QCRestAPIConnect.GetTestCaseParams(test.Id);

            if (testCaseParams.Count > 0)
            {
                for (int indx = 0; indx < testCaseParams.Count; indx++)
                {
                    QCRestAPIConnect.DeleteEntity(ALM_Common.DataContracts.ResourceType.DESIGN_STEP_PARAMETERS, testCaseParams[indx].Id);
                }
            }

            foreach (QCTestCaseStep step in testCaseDesignStep)
            {
                //set item fields
                foreach (ExternalItemFieldBase field in designStepsFields)
                {
                    if (field.ToUpdate || field.Mandatory)
                    {
                        if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                        {
                            if (step.ElementsField.ContainsKey(field.ExternalID))
                            {
                                step.ElementsField[field.ExternalID] = field.SelectedValue;
                            }
                        }
                    }
                }

                step.ElementsField["name"] = identifiedActivity.ActivityName;
                string descriptionTemplate =
                    "<html><body><div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\"><<&Description&&>><br /><<&Parameters&>><br /><<&Actions&>></span></font></div></body></html>";
                string description = descriptionTemplate.Replace("<<&Description&&>>", identifiedActivity.Description);

                QCTestCaseParamsColl testParams = QCRestAPIConnect.GetTestCaseParams(test.Id);
                string paramsSigns = string.Empty;
                if (identifiedActivity.Variables.Count > 0)
                {
                    paramsSigns = "<br />Parameters:<br />";
                    foreach (VariableBase var in identifiedActivity.Variables)
                    {
                        paramsSigns += "&lt;&lt;&lt;" + var.Name.ToLower() + "&gt;&gt;&gt;<br />";
                        //try to add the paramter to the test case parameters list
                        try
                        {
                            QCTestCaseParam newParam = new QCTestCaseParam();

                            //set item fields
                            foreach (ExternalItemFieldBase field in designStepsParamsFields)
                            {
                                if (field.ToUpdate || field.Mandatory)
                                {
                                    if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                                    {
                                        newParam.ElementsField.Add(field.ExternalID, field.SelectedValue);
                                    }
                                    else
                                    {
                                        try { newParam.ElementsField.Add(field.ExternalID, "NA"); }
                                        catch { }
                                    }
                                }
                            }

                            newParam.Name   = var.Name.ToLower();
                            newParam.TestId = test.Id;

                            QCItem itemTestCaseParam = ConvertObjectValuesToQCItem(newParam, ResourceType.TEST_CASE_PARAMETERS);
                            QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_CASE_PARAMETERS, itemTestCaseParam);
                        }
                        catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}"); }
                    }
                }

                description = description.Replace("<<&Parameters&>>", paramsSigns);

                string actsDesc = string.Empty;
                if (identifiedActivity.Acts.Count > 0)
                {
                    actsDesc = "Actions:<br />";
                    foreach (Act act in identifiedActivity.Acts)
                    {
                        actsDesc += act.Description + "<br />";
                    }
                }
                description      = description.Replace("<<&Actions&>>", actsDesc);
                step.Description = description;
                step.ElementsField["expected"] = identifiedActivity.Expected;

                QCItem          itemDesignStep = ConvertObjectValuesToQCItem(step, ResourceType.DESIGN_STEP, true);
                ALMResponseData response       = QCRestAPIConnect.UpdateEntity(ResourceType.DESIGN_STEP, step.Id, itemDesignStep);

                identifiedActivity.ExternalID = step.Id;
            }
        }
        private static bool CreateTestStep(QCTestCase test, Activity activity, ObservableList <ExternalItemFieldBase> designStepsFields, ObservableList <ExternalItemFieldBase> designStepsParamsFields, int stepOrder)
        {
            //create new step
            QCTestCaseStep step = new QCTestCaseStep();

            //set item fields
            foreach (ExternalItemFieldBase field in designStepsFields)
            {
                if (field.ToUpdate || field.Mandatory)
                {
                    if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                    {
                        step.ElementsField.Add(field.ExternalID, field.SelectedValue);
                    }
                    else
                    {
                        try { step.ElementsField.Add(field.ExternalID, "NA"); }
                        catch { }
                    }
                }
            }

            step.ElementsField["name"]       = activity.ActivityName;
            step.ElementsField["parent-id"]  = test.Id;
            step.ElementsField["step-order"] = stepOrder.ToString();

            string descriptionTemplate =
                "<html><body><div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\"><<&Description&&>><br /><<&Parameters&>><br /><<&Actions&>></span></font></div></body></html>";
            string description = descriptionTemplate.Replace("<<&Description&&>>", activity.Description);
            QCTestCaseParamsColl testParams = QCRestAPIConnect.GetTestCaseParams(test.Id);
            string paramsSigns = string.Empty;

            if (activity.Variables.Count > 0)
            {
                paramsSigns = "<br />Parameters:<br />";
                foreach (VariableBase var in activity.Variables)
                {
                    paramsSigns += "&lt;&lt;&lt;" + var.Name.ToLower() + "&gt;&gt;&gt;<br />";
                    //try to add the paramter to the test case parameters list
                    try
                    {
                        QCTestCaseParam newParam = new QCTestCaseParam();

                        //set item fields
                        foreach (ExternalItemFieldBase field in designStepsParamsFields)
                        {
                            if (field.ToUpdate || field.Mandatory)
                            {
                                if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                                {
                                    newParam.ElementsField.Add(field.ExternalID, field.SelectedValue);
                                }
                                else
                                {
                                    try { newParam.ElementsField.Add(field.ExternalID, "NA"); }
                                    catch { }
                                }
                            }
                        }

                        newParam.Name   = var.Name.ToLower();
                        newParam.TestId = test.Id;

                        QCItem itemTestCaseParam = ConvertObjectValuesToQCItem(newParam, ResourceType.TEST_CASE_PARAMETERS);
                        QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_CASE_PARAMETERS, itemTestCaseParam);
                    }
                    catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}"); }
                }
            }
            description = description.Replace("<<&Parameters&>>", paramsSigns);

            string actsDesc = string.Empty;

            if (activity.Acts.Count > 0)
            {
                actsDesc = "Actions:<br />";
                foreach (Act act in activity.Acts)
                {
                    actsDesc += act.Description + "<br />";
                }
            }
            description      = description.Replace("<<&Actions&>>", actsDesc);
            step.Description = description;
            step.ElementsField["expected"] = activity.Expected;

            QCItem          itemDesignStep = ConvertObjectValuesToQCItem(step, ResourceType.DESIGN_STEP);
            ALMResponseData response       = QCRestAPIConnect.CreateNewEntity(ResourceType.DESIGN_STEP, itemDesignStep);

            activity.ExternalID = response.IdCreated;

            if (activity.ExternalID != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }