59 lines
2.5 KiB
C#
59 lines
2.5 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using AyCode.Interfaces.Entities;
|
|
using AyCode.Entities.Locations;
|
|
using AyCode.Interfaces.TimeStampInfo;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace TIAM.Entities.TransferDestinations
|
|
{
|
|
[Table("TransferDestination")]
|
|
public class TransferDestination : LocationBase, ITimeStampInfo
|
|
{
|
|
//[Required(ErrorMessage = "The Username value should be specified.")]
|
|
[DataType(DataType.Text)]
|
|
[Display(Name = "Destination name")]
|
|
public string? Name { get; set; }
|
|
|
|
[DataType(DataType.MultilineText)]
|
|
[Display(Name = "Destination info")]
|
|
public string? Description { get; set; }
|
|
|
|
public DateTime Created { get; set; }
|
|
public DateTime Modified { get; set; }
|
|
|
|
public TransferDestination() { }
|
|
public TransferDestination(double latitude, double longitude, string address) : this(Guid.NewGuid(), latitude, longitude, address) { }
|
|
public TransferDestination(Guid id, double latitude, double longitude, string address) : base(Guid.NewGuid(), latitude, longitude, address) { }
|
|
public TransferDestination(Guid id, string name, double latitude, double longitude, string address) : base(id, latitude,longitude, address) { }
|
|
public TransferDestination(Guid id, string name, string description, double latitude, double longitude, string address) : base(id, latitude,longitude, address) { }
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
|
public class MinPasswordLengthAttribute : ValidationAttribute
|
|
{
|
|
int MinLength { get; }
|
|
public MinPasswordLengthAttribute(int minLength, string errorMsg) : base(errorMsg)
|
|
{
|
|
MinLength = minLength;
|
|
}
|
|
|
|
public override bool IsValid(object value)
|
|
{
|
|
return ((string)value).Length >= MinLength;
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
|
public class EmailAttribute : ValidationAttribute
|
|
{
|
|
public override bool IsValid(object value)
|
|
{
|
|
return Regex.IsMatch((string)value, @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
|
|
+ "@"
|
|
+ @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$");
|
|
}
|
|
}
|
|
}
|
|
|