using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
namespace LeafWeb.WebCms.Models
{
public class LeafDataQuery
{
private const string FloatingPointRegex = @"^([-+]?[0-9]*\.[0-9]+|[0-9]+)$";
/// Query
[Display(Name = "Search", Description = "General query")]
public string q { get; set; }
[Display(Name = "Site ID", Description = "The site's name/Fluxnet ID, if known")]
[RegularExpression(@".{3,}", ErrorMessage = "Specify at least three characters")]
public string siteid { get; set; }
[Display(Name = "Species Name")]
[RegularExpression(@".{3,}", ErrorMessage = "Specify at least three characters")]
public string species { get; set; }
/// Site latitude, northern hemisphere positive
[Display(Name = "Latitude")]
[RegularExpression(@"^-?([0-9]|[1-8][0-9]|90)$", ErrorMessage = "Site latitude, northern hemisphere positive, -90 – 90")]
public string lat { get; set; }
[Display(Name = "Range")]
[RegularExpression(@"^([0-9]|[1-8][0-9]|90)$", ErrorMessage = "± latitude degrees")]
public string latr { get; set; }
/// Site longitude, east positive
[Display(Name = "Longitude")]
[RegularExpression(@"^-?([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "Site longitude, east positive, -180 – 180")]
public string lon { get; set; }
[Display(Name = "Range")]
[RegularExpression(@"^([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "± longitude degrees")]
public string lonr { get; set; }
/// Sample CO2 concentration
[Display(Name = "CO2 response curves (CO2S)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
public string co2s { get; set; }
/// PAR measured by the in-chamber quantum sensor
[Display(Name = "Light response curves (PARi)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
public string pari { get; set; }
/// temperature of leaf thermocouple
[Display(Name = "Temperature response curves (Tleaf)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
public string tleaf { get; set; }
/// DeltaF/Fm, the fraction of absorbed PSII photons that are used in photochemistry
[Display(Name = "Fluorometry measurements (PhiPS2)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
public string phips2 { get; set; }
public bool HasExtendedParameters =>
!(
string.IsNullOrEmpty(siteid)
&& string.IsNullOrEmpty(species)
&& string.IsNullOrEmpty(lat)
&& string.IsNullOrEmpty(latr)
&& string.IsNullOrEmpty(lon)
&& string.IsNullOrEmpty(lonr)
&& string.IsNullOrEmpty(co2s)
&& string.IsNullOrEmpty(pari)
&& string.IsNullOrEmpty(tleaf)
&& string.IsNullOrEmpty(phips2)
);
}
}