101 lines
2.7 KiB
C#
101 lines
2.7 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
using Sieve.Attributes;
|
|
|
|
namespace Events.MVC.Models.People;
|
|
|
|
public class PersonViewModel : IValidatableObject
|
|
{
|
|
[Sieve(CanSort = true)]
|
|
public int Id { get; set; }
|
|
|
|
[Display(Name = "First name")]
|
|
[StringLength(100)]
|
|
public string? FirstName { get; set; }
|
|
|
|
[Display(Name = "Last name")]
|
|
[StringLength(100)]
|
|
public string? LastName { get; set; }
|
|
|
|
[Display(Name = "First name (transcription)")]
|
|
[Required]
|
|
[StringLength(100)]
|
|
[Sieve(CanSort = true)]
|
|
public string FirstNameTranscription { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Last name (transcription)")]
|
|
[Required]
|
|
[StringLength(100)]
|
|
[Sieve(CanSort = true)]
|
|
public string LastNameTranscription { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Address")]
|
|
[StringLength(200)]
|
|
public string? AddressLine { get; set; }
|
|
|
|
[Display(Name = "Postal code")]
|
|
[StringLength(20)]
|
|
public string? PostalCode { get; set; }
|
|
|
|
[Display(Name = "City")]
|
|
[StringLength(100)]
|
|
public string? City { get; set; }
|
|
|
|
[Display(Name = "Address country")]
|
|
[StringLength(100)]
|
|
public string? AddressCountry { get; set; }
|
|
|
|
[Display(Name = "E-mail")]
|
|
[EmailAddress]
|
|
[StringLength(255)]
|
|
[Sieve(CanSort = true)]
|
|
public string? Email { get; set; }
|
|
|
|
[Display(Name = "Phone")]
|
|
[StringLength(50)]
|
|
public string? ContactPhone { get; set; }
|
|
|
|
[Display(Name = "Birth date")]
|
|
[Required]
|
|
[Sieve(CanSort = true)]
|
|
public DateOnly? BirthDate { get; set; }
|
|
|
|
[Display(Name = "Document number")]
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string DocumentNumber { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Country")]
|
|
[Required]
|
|
[StringLength(3)]
|
|
[Sieve(CanFilter = true)]
|
|
public string CountryCode { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Full name")]
|
|
public string FullName { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Full name (transcription)")]
|
|
[Sieve(CanFilter = true)]
|
|
public string FullNameTranscription { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Country")]
|
|
[Sieve(CanSort = true)]
|
|
public string CountryName { get; set; } = string.Empty;
|
|
|
|
[Display(Name = "Registrations")]
|
|
[Sieve(CanSort = true)]
|
|
public int RegistrationsCount { get; set; }
|
|
|
|
public List<SelectListItem> CountryOptions { get; set; } = [];
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(Email) && string.IsNullOrWhiteSpace(ContactPhone))
|
|
{
|
|
yield return new ValidationResult(
|
|
Constants.Messages.EmailOrContactPhoneRequired,
|
|
new[] { nameof(Email), nameof(ContactPhone) });
|
|
}
|
|
}
|
|
}
|