41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
namespace LaaProduction.Search.Models.Wildcard
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
|
|
public class WildcardInputModel
|
|
{
|
|
private String token;
|
|
private IEnumerable<String> fields = Array.Empty<String>();
|
|
|
|
[Required]
|
|
[StringLength(50, MinimumLength = 1)]
|
|
[RegularExpression("^[0-9 a-z-A-Z]+$")]
|
|
public String Token
|
|
{
|
|
get => this.token;
|
|
set => this.token = value?.Replace(" ", "")?.Trim();
|
|
}
|
|
|
|
public String Fields
|
|
{
|
|
get => String.Join(",", this.FieldsArray);
|
|
set => this.FieldsArray = $"{value}".Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
}
|
|
|
|
internal IEnumerable<String> FieldsArray { get; set; }
|
|
|
|
internal IEnumerable<String> GetRequiredFields(IEnumerable<String> allFields)
|
|
{
|
|
if (this.fields.Any())
|
|
{
|
|
return this.fields.Intersect(allFields, StringComparer.OrdinalIgnoreCase);
|
|
}
|
|
|
|
return allFields;
|
|
}
|
|
}
|
|
}
|