Files
ContactsApp/Models/Contact.cs
2025-12-14 18:15:23 +03:00

34 lines
718 B
C#

using System.ComponentModel.DataAnnotations;
using System.Net.Mail;
namespace ContactsApp
{
public class Contact
{
public Guid Id { get; }
public string Name { get; set; }
public string? Email { get; set; }
public string Phone { get; set; }
public Contact(string name, string? email, string phone)
{
Id = Guid.NewGuid();
Name = name;
try
{
var addr = new MailAddress(email);
Email = email;
}
catch (Exception ex)
{
throw new Exception("Invalid email");
}
Phone = phone;
}
}
}