public static List <string> GetFieldValuesByRequestField(CaseEditRequestField editRequestField)
        {
            var list = new List <string>();

            switch (editRequestField.FieldType)
            {
            case "CheckBox":
                var checkBoxfirst = editRequestField?.FieldValues?.First();
                if (checkBoxfirst?.Value != null && checkBoxfirst?.FieldId != null)
                {
                    string val = $"{checkBoxfirst.FieldId}|{checkBoxfirst.Value.ToString()}";
                    list.Add(val);
                }
                break;

            case "Comment":
                var commentFirst = editRequestField?.FieldValues?.First();
                if (commentFirst?.Value != null && commentFirst?.FieldId != null)
                {
                    string val = $"{commentFirst.FieldId}|{commentFirst.Value.ToString()}";
                    list.Add(val);
                }
                break;

            case "Number":
                var numberFirst = editRequestField?.FieldValues?.First();
                if (numberFirst?.Value != null && numberFirst?.FieldId != null)
                {
                    string val = $"{numberFirst.FieldId}|{numberFirst.Value.ToString()}";
                    list.Add(val);
                }
                break;

            case "Text":
                var textFirst = editRequestField?.FieldValues?.First();
                if (textFirst?.Value != null && textFirst?.FieldId != null)
                {
                    string val = $"{textFirst.FieldId}|{textFirst.Value.ToString()}";
                    list.Add(val);
                }
                break;

            case "Date":
                var dateFirst = editRequestField?.FieldValues?.First();
                if (dateFirst?.Value != null && dateFirst?.FieldId != null)
                {
                    try
                    {
                        DateTime currentDate = (DateTime)dateFirst.Value;
                        if (currentDate != null)
                        {
                            string val = $"{dateFirst.FieldId}|{currentDate:MM-dd-yyyy}";
                            list.Add(val);
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                }
                break;

            case "SingleSelect":
                var singleFirst = editRequestField?.FieldValues?.First();
                if (singleFirst?.Value != null && singleFirst?.FieldId != null)
                {
                    string val = $"{singleFirst.FieldId}|{singleFirst.Value.ToString()}";
                    list.Add(val);
                }
                break;

            case "MultiSelect":
                var multiFirst = editRequestField?.FieldValues?.First();
                if (multiFirst?.Value != null && multiFirst?.FieldId != null)
                {
                    string val = $"{multiFirst.FieldId}|{multiFirst.Value.ToString()}";
                    list.Add(val);
                }
                break;
            }
            return(list);
        }
Exemplo n.º 2
0
        public static List <string> GetFieldValuesByRequestField(CaseEditRequestField editRequestField)
        {
            var list = new List <string>();

            switch (editRequestField.FieldType)
            {
            case Constants.FieldTypes.CheckBox:
                var checkBoxfirst = editRequestField.FieldValues?.First();
                if (checkBoxfirst?.Value != null && checkBoxfirst.FieldId != 0)
                {
                    string val;
                    if (checkBoxfirst.Value.ToString() == "1" || checkBoxfirst.Value.ToString() == "checked")
                    {
                        val = $"{checkBoxfirst.FieldId}|checked";
                    }
                    else
                    {
                        val = $"{checkBoxfirst.FieldId}|unchecked";
                    }
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.Comment:
                var commentFirst = editRequestField.FieldValues?.First();
                if (commentFirst?.Value != null && commentFirst.FieldId != 0)
                {
                    var val = $"{commentFirst.FieldId}|{commentFirst.Value.ToString().Replace("</p>", "<br>").Replace("<p>", "").Replace("<div>", "").Replace("</div>", "<br>").Replace("&nbsp;", "").Replace("</span>", "").Replace("<span style=\"font-size: 1rem;\">", "").Replace("</br>", "<br>")}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.Number:
                var numberFirst = editRequestField.FieldValues?.First();
                if (numberFirst?.Value != null && numberFirst.FieldId != 0)
                {
                    var val = $"{numberFirst.FieldId}|{numberFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.Text:
                var textFirst = editRequestField.FieldValues?.First();
                if (textFirst?.Value != null && textFirst.FieldId != 0)
                {
                    var val = $"{textFirst.FieldId}|{textFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.Date:
                var dateFirst = editRequestField.FieldValues?.First();
                if (dateFirst?.Value != null && dateFirst.FieldId != 0)
                {
                    try
                    {
                        var dateResult =
                            DateTime.TryParseExact(dateFirst.Value.ToString(),
                                                   "yyyy-MM-dd",
                                                   null,
                                                   DateTimeStyles.None,
                                                   out DateTime date);
                        if (dateResult)
                        {
                            var val = $"{dateFirst.FieldId}|{date:yyyy-MM-dd}";
                            list.Add(val);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }

                break;

            case Constants.FieldTypes.SingleSelect:
                var singleSelect = editRequestField.FieldValues?.First();
                if (singleSelect?.Value != null)
                {
                    var val = $"{singleSelect.FieldId}|{singleSelect.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.EntitySearch:
                var entitySearch = editRequestField.FieldValues?.First();
                if (entitySearch?.Value != null && entitySearch.Value != "0" && entitySearch.FieldId != 0)
                {
                    var val = $"{entitySearch.FieldId}|{entitySearch.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.EntitySelect:
                var entitySelect = editRequestField?.FieldValues?.First();
                if (entitySelect?.Value != null && entitySelect.FieldId != 0)
                {
                    var val = $"{entitySelect.FieldId}|{entitySelect.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.MultiSelect:
                var multiFirst = editRequestField?.FieldValues?.First();
                if (multiFirst?.Value != null)
                {
                    var val = $"{multiFirst.FieldId}|{multiFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case Constants.FieldTypes.Audio:
                var audioFirst = editRequestField?.FieldValues?.First();
                if (audioFirst?.Value != null && audioFirst.FieldId != 0)
                {
                    var val = $"{audioFirst.FieldId}|{audioFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;
            }

            return(list);
        }
Exemplo n.º 3
0
        public static List <string> GetFieldValuesByRequestField(CaseEditRequestField editRequestField)
        {
            var list = new List <string>();

            switch (editRequestField.FieldType)
            {
            case "CheckBox":
                var checkBoxfirst = editRequestField?.FieldValues?.First();
                if (checkBoxfirst?.Value != null && checkBoxfirst?.FieldId != null)
                {
                    string val = $"{checkBoxfirst.FieldId}|{checkBoxfirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "Comment":
                var commentFirst = editRequestField?.FieldValues?.First();
                if (commentFirst?.Value != null && commentFirst?.FieldId != null)
                {
                    string val = $"{commentFirst.FieldId}|{commentFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "Number":
                var numberFirst = editRequestField?.FieldValues?.First();
                if (numberFirst?.Value != null && numberFirst?.FieldId != null)
                {
                    string val = $"{numberFirst.FieldId}|{numberFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "Text":
                var textFirst = editRequestField?.FieldValues?.First();
                if (textFirst?.Value != null && textFirst?.FieldId != null)
                {
                    string val = $"{textFirst.FieldId}|{textFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "Date":
                var dateFirst = editRequestField?.FieldValues?.First();
                if (dateFirst?.Value != null && dateFirst?.FieldId != null)
                {
                    try
                    {
                        var dateResult =
                            DateTime.TryParseExact(dateFirst.Value.ToString(),
                                                   "yyyy-MM-dd",
                                                   null,
                                                   DateTimeStyles.None,
                                                   out DateTime date);
                        if (dateResult)
                        {
                            var val = $"{dateFirst.FieldId}|{date:yyyy-MM-dd}";
                            list.Add(val);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }

                break;

            case "SingleSelect":
                var singleSelect = editRequestField?.FieldValues?.First();
                if (singleSelect?.Value != null && singleSelect?.Value != "0" && singleSelect?.FieldId != null)
                {
                    string val = $"{singleSelect.FieldId}|{singleSelect.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "EntitySearch":
                var entitySearch = editRequestField?.FieldValues?.First();
                if (entitySearch?.Value != null && entitySearch?.Value != "0" && entitySearch?.FieldId != null)
                {
                    string val = $"{entitySearch.FieldId}|{entitySearch.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "EntitySelect":
                var entitySelect = editRequestField?.FieldValues?.First();
                if (entitySelect?.Value != null && entitySelect?.FieldId != null)
                {
                    string val = $"{entitySelect.FieldId}|{entitySelect.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "MultiSelect":
                var multiFirst = editRequestField?.FieldValues?.First();
                if (multiFirst?.Value != null && multiFirst?.FieldId != null)
                {
                    string val = $"{multiFirst.FieldId}|{multiFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;

            case "Audio":
                var audioFirst = editRequestField?.FieldValues?.First();
                if (audioFirst?.Value != null && audioFirst?.FieldId != null)
                {
                    string val = $"{audioFirst.FieldId}|{audioFirst.Value.ToString()}";
                    list.Add(val);
                }

                break;
            }

            return(list);
        }