Forum-Inzynieria1/Trunk/Server/Forum/MailSender/Models/MailModel.cs

41 lines
1.3 KiB
C#

using System.ComponentModel.DataAnnotations;
using MailDTO;
using System.ComponentModel.DataAnnotations.Schema;
namespace MailSender.Models
{
[Table("Mail")]
public class MailModel
{
[Key]
public int Id { get; set; }
//[ForeignKey]
//public int UserId //id usera ktory wyslal maila
[Display(Name = "Temat")]
[Required(AllowEmptyStrings = false)]
public string Subject { get; set; }
[DataType(DataType.EmailAddress)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Musisz wprowadzić adres e-mail odbiorcy")]
[RegularExpression(".*@.*\\..*", ErrorMessage = "Zły format")]
[Display(Name = "Adres odbiorcy")]
[EmailAddress(ErrorMessage ="Zły format")]
public string EMailTo { get; set; }
[Display(Name ="Odpowiedź")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Proszę wprowadzić odpowiedź")]
[DataType(DataType.MultilineText)]
[StringLength(500, ErrorMessage = "Message has to have between 1 and 500 chars", MinimumLength = 1)]
public string Content { get; set; }
public MailModel(MailDTO.MailDTO DTO)
{
this.Content = DTO.Content;
this.EMailTo = DTO.EMailTo;
this.Subject = DTO.Subject;
}
}
}