using System; using System.ComponentModel.DataAnnotations; using EnVisage.Code; namespace EnVisage.Models { public class ContactModel : IBaseModel { public Guid Id { get; set; } [Required] [MaxLength(100)] [Display(Name="First Name")] public string FirstName { get; set; } [MaxLength(100)] [Required] [Display(Name="Last Name")] public string LastName { get; set; } [Required] [EmailAddress] [MaxLength(100)] public string Email { get; set; } [MaxLength(100)] public string Phone { get; set; } public ContactType Type { get; set; } [Display(Name="Contact Classification")] public InternalContactClassification ContactClassification { get; set; } [UIHint("CompanySingleSelect")] public Guid ParentId { get; set; } public int ProjectLinksCount { get; set; } public ContactModel() { Id = new Guid(); } public ContactModel(Guid parentId) { Id = new Guid(); ParentId = parentId; } /// /// Copies data from model to DAL object. /// /// A target DAL object. public void CopyTo(Contact dbObj) { if (dbObj == null) throw new ArgumentNullException(); dbObj.Type = Type; dbObj.FirstName = FirstName; dbObj.LastName = LastName; dbObj.Phone = Phone; dbObj.Email = Email; dbObj.ParentId = ParentId; dbObj.ContactClassification = (int)ContactClassification; // dbObj.UserId = (Author != null) ? new Guid(Author.Id) : new Guid(User.Identity.GetID()); } } }