71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
using System.Collections.Specialized;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace LeafWeb.WebCms.Models
|
|
{
|
|
public class LeafDataQuery
|
|
{
|
|
/// <summary>Query</summary>
|
|
[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; }
|
|
|
|
/// <summary>Site latitude, northern hemisphere positive</summary>
|
|
[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; }
|
|
|
|
/// <summary>Site longitude, east positive</summary>
|
|
[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; }
|
|
|
|
static LeafDataQuery()
|
|
{
|
|
//Mapper.CreateMap<LeafInputCreate, LeafInput>()
|
|
// .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
|
//Mapper.CreateMap<LeafInput, LeafInputCreate>()
|
|
// .ForMember(dest => dest.PhotosynthesisType, opt => opt.Ignore());
|
|
}
|
|
|
|
public LeafDataQuery()
|
|
{
|
|
//PhotosynthesisType = new SelectListViewModel();
|
|
}
|
|
|
|
public NameValueCollection GetNameValueCollection(string prefix="")
|
|
{
|
|
var nvs = new NameValueCollection();
|
|
|
|
prefix =
|
|
string.IsNullOrEmpty(prefix)
|
|
? ""
|
|
: prefix + ".";
|
|
|
|
foreach (var pi in typeof(LeafDataQuery).GetProperties())
|
|
{
|
|
var value = pi.GetValue(this, null);
|
|
if (value == null)
|
|
continue;
|
|
nvs.Add(prefix + pi.Name, value?.ToString());
|
|
}
|
|
|
|
return nvs;
|
|
}
|
|
}
|
|
} |